Bitcoin Forum
May 28, 2024, 02:08:28 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: armoryd not broadcasting transactions  (Read 960 times)
valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 25, 2016, 01:56:08 PM
 #1

Hi there,

I've installed Armory on an Ubuntu server and changed armoryd a bit to respond to my needs:
 - added some methods
 - untied these methods from the current wallet (each method receives the wallet name to work with)

In particular, I created a method which handles the transaction creation and broadcasting for a given wallet.

It is composed of bits of:
 - CreateUsTxForMany
 - SignAsciiTransaction
 - SendAsciiTransaction

The last part, though, does not seem to work.
The following is the piece of code directly from armoryd.py:
Code:
pytx = signedTran.getSignedPyTx()
newTxHash = pytx.getHash()

def sendGetDataMsg():
msg = PyMessage('getdata')
msg.payload.invList.append( [MSG_INV_TX, newTxHash] )
self.NetworkingFactory.sendMessage(msg)
LOGINFO('Sending transaction: ' + str(msg.pprint()))
 
self.NetworkingFactory.sendTx(pytx)
reactor.callLater(3, sendGetDataMsg)
   
return {'data': pytx.getHashHex(BIGENDIAN)}

It returns the transaction hash, but does not publish the transaction itself.

I wonder where to start the investigation.

The armory error logs report that Armory fails to process the PyMessage from the LOGINFO part in sendGetDataMsg function. That always remains None.
The armory logs report the GETDATA message correctly:
Code:
Bitcoin-Network-Message -- GETDATA
   Magic:   f9beb4d9
   Command: getdata
   Payload: 37 bytes

   Message(getdata):
      TX   : 29a7f012b.....

But then I can see that Armory starts a side-scan of the totally irrelevant wallet (in fact, the Active Wallet which is ignored in this case):
Code:
-WARN  - 1464184077: (BDM_supportClasses.cpp:44) Updating SSH last scanned
-INFO  - 1464184077: (BDM_supportClasses.cpp:246) Done with side scan of wallet abcd...

Can you help me and guide where to look for the problem and how to force Armory to side scan my specific wallet and not the Active one?

Thanks in advance.
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 25, 2016, 10:20:18 PM
 #2

I haven't tested this broadcasting code directly but it looks valid. You should figure out if the tx is valid at first. I suggest you look at your bitcoin node debug log to identify the error message attached with this tx. Once you have figured if the it's the tx that is off or the broadcasting code, we can figure out the next step.


valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 26, 2016, 01:57:49 PM
 #3

I tried with a new wallet which has no transaction history.

Actually, the first transaction seems to have been broadcast successfully.

But it corrupts something in the transaction history section, so the LISTTRANSACTIONS command issues an error:
Code:
Traceback (most recent call last):
  File "/home/deployer/BitcoinArmory/armoryengine/Decorators.py", line 79, in inner
    rv = func(*args, **kwargs)
  File "/home/deployer/BitcoinArmory/armoryd.py", line 1844, in jsonrpc_listtransactions
    cppHead = TheBDM.bdv().getHeaderPtrForTx(cppTx)
  File "/home/deployer/BitcoinArmory/CppBlockUtils.py", line 2136, in getHeaderPtrForTx
    def getHeaderPtrForTx(self, *args): return _CppBlockUtils.BlockDataViewer_getHeaderPtrForTx(self, *args)
RuntimeError: TxRef in Tx object is not set, cannot get header ptr

Most probably, after this moment the wallet will not be able to broadcast transactions. I still need to confirm it, but this is my original problem and the previous wallets I used to do the checks had the same issue with the transaction list after the first successful broadcast.

What can be wrong? Can you help me investigate this issue?

Thanks.
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 26, 2016, 04:37:51 PM
 #4

Are you spending without change?

goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 26, 2016, 06:01:53 PM
 #5

Also, please double check these wallets on the GUI version.

valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 27, 2016, 06:49:58 AM
 #6

I'll check in the GUI version and let you know.

In the meantime, the code I use for creating and broadcasting the transaction is this:
Code:
# Destinations array
scriptValuePairs = []

# -- user destination (toAddress)
ustxScr = getScriptForUserString(toAddress, self.serverWltMap, self.convLBDictToList())
scriptValuePairs.append([ustxScr['Script'], JSONtoAmount(amount)])

# -- my destination (my primary address)
ustxScr = getScriptForUserString(primaryAddr, self.serverWltMap, self.convLBDictToList())
scriptValuePairs.append([ustxScr['Script'], JSONtoAmount(serviceFee)])

# Create unsigned transaction (self.curWlt is substituted by the wallet if a valid walletIDB58 is provided)
tran = self.create_unsigned_transaction(scriptValuePairs, wantfee=fee, walletIDB58=wltArmory.uniqueIDB58)

# Unserialize ascii transaction
ustxObj = UnsignedTransaction().unserializeAscii(tran)

# Unlock the source wallet to sign the transaction
try:
   crpPassphrase = SecureBinaryData(str(passphrase))
   wltArmory.unlock(securePassphrase=crpPassphrase,
                      tempKeyLifetime=int(5)) # unlock for 5 sec
finally:
   crpPassphrase.destroy() # Ensure SBD is destroyed.

# Sign transaction
signedTran = self.sign_transaction(ustxObj, walletIDB58=wltArmory.uniqueIDB58)
if signedTran:
   if not signedTran.verifySigsAllInputs():
      return {'error': 'Incomplete transaction. It needs more signatures.'}

   pytx = signedTran.getSignedPyTx()
   newTxHash = pytx.getHash()
   
   def sendGetDataMsg():
      msg = PyMessage('getdata')
      msg.payload.invList.append( [MSG_INV_TX, newTxHash] )
      self.NetworkingFactory.sendMessage(msg)
      LOGINFO('Sending transaction: ' + str(msg.pprint()))
   
   self.NetworkingFactory.sendTx(pytx)
   reactor.callLater(3, sendGetDataMsg)

These are bits of the original code from armoryd.py. Am I missing anything here?
valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 27, 2016, 01:47:34 PM
 #7

I imported the wallet into the Armory GUI, restarted it and waited for it to rescan the db. But it does not find any transaction in this wallet. Actually, it says the wallet's balance is 0, while the armory daemon in the supernode mode shows correctly the balance.

I tested on 2 completely separated armory instances located on 2 different servers and having nothing in common.

Any other idea where to investigate?
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 27, 2016, 02:56:42 PM
 #8

supernode? You using 0.93?

valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 27, 2016, 03:56:08 PM
 #9

Yep, apparently, 0.93. I got it in March.

And another update. Apparently, the list transactions does not work with unconfirmed transactions. After my transactions got the confirmations, the ListTransactions command worked again.

Now I created another transaction and the transactions list is broken again: transaction list is unavailable, the transaction id can not be found etc. The GetLedger command works just fine, though.

So, I'm waiting for some time for the confirmations to arrive and will retry again and will let you know.

Do you think I should upgrade to 0.94 as this problem might have already been solved?
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 27, 2016, 04:41:20 PM
 #10

Do you think I should upgrade to 0.94 as this problem might have already been solved?

You should

valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 28, 2016, 08:11:41 PM
 #11

I'll give it a try and let you know. Thanks.
valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 29, 2016, 04:36:03 PM
 #12

OK, the new 0.94.1 version has the same problem.

After the first transaction is out, while it is unconfirmed, there is no way to send other transactions. In fact, the method create_unsigned_transaction returns
Code:
"Coin selection failed. This shouldn't happen."

This is the ledger extract:
Code:
{
        "amount": 0.0002,
        "blockhash": "",
        "blocktime": 0,
        "changerecip": "13EBMGZR1xvNM5q267CnVZuiGztYeRXrcK",
        "confirmations": -4294553343,
        "direction": "send",
        "fee": 0.0001,
        "firstrecip": "18koHPBzcdqcbZ7KJRHdzgb8We5GhDLUdN",
        "netdiff": -0.0003,
        "txid": "756a4b9c9bb871a876bb44cafd23c9263284db5cabbb0b05ba567b60dcc7385e",
        "txsize": 291,
        "txtime": 1464539257,
        "wallet": "2PbtaKW7"
    }


Any ideas on how to solve this problem?
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 29, 2016, 07:11:45 PM
 #13

How many inputs do you have in the wallet? Are you trying to spend unconfirmed change? Did you create the ustx with enableZC = True?

valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 30, 2016, 08:59:48 AM
 #14

I checked the IGNOREZC. It's false by default. I can't see any enableZC parameter...

The wallet has only one receive transaction.

The send transactions I try to create have 2 + 1 outputs: 2 destination addresses + 1 for the change.
After the transaction is published, the whole wallet balance becomes this:
Code:
{
"unspent": 0.0003
"full": 0.0003
"ultimate": 0.0003
"unconf": 0
"spendable": 0
"total": 0.0003
"spend": 0
"unconfirmed": 0
}
valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 30, 2016, 09:46:33 AM
 #15

Apparently, my problem is that this piece of code does not work as expected:
Code:
if spendBal < totalSend + fee:
         raise NotEnoughCoinsError, "You have %s satoshis which is not enough to send %s satoshis with a fee of %s."

The spendBal should be 0 and thus must have prevented the further creation of the transaction for publishing. Instead, somehow, this piece is skipped and the transaction gets created on an unconfirmed change. I'll try to investigate and fix it.

However, can you still tell me why I can't see a list of transactions which includes one ZC transaction? I mean, should I check the ledger first? And after the ledger shows there are no ZC transactions, only after that I will be able to see the full list of transactions? Is this a correct logic?
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
May 30, 2016, 10:12:19 AM
Last edit: June 01, 2016, 02:18:40 PM by goatpig
 #16

https://github.com/goatpig/BitcoinArmory/blob/master/armoryengine/ArmoryUtils.py#L114

Try with this. It looks like one call returns ZC outputs while the other doesn't and it gets confused there. Most likely a bug. I'll to have look into it at some point.


valshy (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
June 01, 2016, 09:51:13 AM
 #17

OK, I will limit my use to the ledger as this seems to provide quite enough of info about the transactions.
Thanks for the support. Smiley
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!