miracle2k / ripple-python

Ripple-related routines in Python. Might become a proper client library later.
49 stars 31 forks source link

Can't submit offline signed transaction to my ripple node #8

Open skinderis opened 5 years ago

skinderis commented 5 years ago

I am testing transaction submitting operations with my ripple testnet node, but I can't submit offline signed transaction to my testnet node. Firstly I prepare some transaction data:

{ 'Account': 'rU6sW4Vp8FFeoobZaxMpbDYuCkJyVG8DMf', 'Amount': '12345599', 'Destination': 'rw47Lr3B1hFvTC2vXFBb6nyZGjntKGDNPf', 'TransactionType': 'Payment', 'Sequence': 1, 'Fee': '12' }

Then call sign_transaction(tx, secret_key) method. It returns:

{'Account': 'rU6sW4Vp8FFeoobZaxMpbDYuCkJyVG8DMf', 'Amount': '12345599', 'Destination': 'rw47Lr3B1hFvTC2vXFBb6nyZGjntKGDNPf', 'TransactionType': 'Payment', 'Sequence': 1, 'Fee': '12', 'Flags': 2147483648, 'SigningPubKey': '02A1E296BFBF7F06DF12F0D093AE350FCB1766A16BF1042F870F6B46BBEBB4EA4C', 'TxnSignature': '3044022047C37B978457D653911EF9A55F537AEDAADE434C7EE80B090D50911CCC7BC6950220512530903CF534638C86A1DEDE630D9D6C24D17A99559860B9E5925644182D6D' }

After I get TxnSignature value, I call Ripple RPC method submit and provide tx_blob with TxnSignature value:

'{ "method": "submit", "params": [{ "tx_blob": "3044022001069CB1E37DFF7EE5735686E3B8B71E5A85452E0C8794B23813523F3F8515C70220503D1B2A31AAC319241D003813A9F9AF2BD2C722C5FD8A1D9547900A8057C9AD" }] }'

The result is this error:

{'result': {'error': 'invalidTransaction', 'error_exception': 'Non-object in array', 'request': {'command': 'submit', 'tx_blob': '3044022001069CB1E37DFF7EE5735686E3B8B71E5A85452E0C8794B23813523F3F8515C70220503D1B2A31AAC319241D003813A9F9AF2BD2C722C5FD8A1D9547900A8057C9AD'}, 'status': 'error'}}

What I do wrong? And how can I fix this problem? Thank you for you help very much!

skinderis commented 5 years ago

@miracle2k maybe you have some ideas?

skinderis commented 5 years ago

UPDATE: I found out, that tx_blob is not TxnSignature. But gotta find out how to get tx_blob value when I have TxnSignature and SigningPubKey values.

skinderis commented 5 years ago

SOLVED:

from ripple.serialize import serialize_object
tx_blob = serialize_object(tx)

serialize_object method returns tx_blob value which can be passed to Ripple submit RPC method.