I am trying using the Monero-python library and trying to create a transaction (without relaying it), and then publish the tx using the hex output using the relay_tx method on the monero-wallet-rpc server API. I can't get monero-wallet-rpc to accept my my hex whether i try to send it with curl or python, but I'm probably misunderstanding something.
import binascii
from monero.wallet import Wallet,JSONRPCWallet
w = Wallet(JSONRPCWallet(port=28088))
txs=w.accounts[0].transfer('89Erdfa8b7d7LqKGAy5WTGK3ideUPBPW34fVj51bdzBdFNQfJgDBKNkgXUyNrSUNYRX7cZbdRDf7RJtUcig21kMrBagYvmY', Decimal(0.00031), relay=False)
for tx in txs:
tx_hex_str = binascii.hexlify(tx.blob).decode()
response = w._backend.raw_request('relay_tx', params={"hex": tx_hex_str})
The error:
JSON RPC error:
{
"error": {
"code": -27,
"message": "Failed to parse tx metadata."
},
"id": 0,
"jsonrpc": "2.0"
}
Traceback (most recent call last):
File "test.py", line 42, in <module>
resp = w._backend.raw_request('relay_tx', params={"hex": tx_hex_str})
File "/home/user/Downloads/monero-dev/monero-python/monero/backends/jsonrpc/wallet.py", line 438, in raw_request
raise RPCError(
monero.backends.jsonrpc.exceptions.RPCError: Method 'relay_tx' failed with RPC Error of unknown code -27, message: Failed to parse tx metadata.
i verified that monero is up to date and tx_hex_str is valid and can be decoded on https://xmrchain.org/rawtx (the hex being sent can be found in the curl command below)
curl also fails
curl http://localhost:28088/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"relay_tx","params":{"hex":"0200010200108787b720969914adc19801929301ddfd07fe9108860acfd70953fa0aae01ea0ada1cb604a903bf0a56cefae6a6db36cf1e42a467223ff2e86d6b0c49af458c03fe7126b133be460202000387a7f0b649332767a46a0ac5bc7bff687c55ff730ec3c532289e67ef646361e03a0003cf789207e5063e01a19abba76e1ce87a6f423067f194d79fbe4a000260e2623f5e2c01dfd5d0d87a061d538b98f56a292dda419b3e8c7a275aaa3a2f57a916508b0d8c02090157c53322b1c0ae890680daae3ad4017501574589d4b7c8272d2ac973b84af8d69503ae40450024bddaba563376e909b5c06363bb2e32cba7cb2616c5cd97f12cba3c93d832212cd48f5a60a049d78e33258a53b9126f3312eb423954ed01bcfadd917c9d59922b8c28f83cda5e7f0c6b8b8f70324907c0671969467788edc85185b56930306e1dcd0687ac9739a9b27b54d4acee5388781214b2d51659d9ae83f7cb59bb8376d1c80b6718f1b8b03da3e854e763b3c5817cf3c232266e106bb8e8376075fe31fc382608aadc84ce9eef6bdceacc8722d7bde19fa9392500626a371b6160a0cd14ab6b4afa37029a5a45c96726a54686c7f376a4f72ed701177bde92b65765fbaed8608d9de1254faf3ebedfde982b25338c1cd8d238a206077bdbf2eefcb73d0ea8b237129738b950e765c106a1e4cc95f8c7bd5c38348217fbc40c415376e25106a43a62bf8005fd7ced7c8c7beda2004d9ea73ae73e90f70201916eeba2f60ac94e2063c510b3e6ece98aaab2871bfb658623fbf7bce7e20a0facc6a0091b7cd0e2f1e645db5639cc3e99f888eda8a4a04b9217195c7516687c149d0a636859e13735d1bf8ecb8168537d63086b3e501bf63dc4f3769e44ee2acaca970fae919f0a6460bb43e7de22d2f2a3bd23ee81e88be75835af2fefc970675bd3d232bbfe1a30cb996c83b8baed3f21b57fda49b76bdc77eedd82b60787272f31cfa0f3f44e779ec7ce4c96832748e7df64970d29c348785721c24f5b1ca576689f6af1fd10dc8b365847e162ebd9b16e9147d50da210d83ef1312881cacaee0ac8ffe62aa80559cd178b076041d7cdfe629b7ce4039c3f4f64879e7c25979689f12ef1a751a5bb057c9f86b5f871316eae27bcacacd56bb5ec2b2c8f3a1daed84acd4b4907f8ae906ff7d0e97085945ae84ee223bc14782c28632b4488db44191ddd918d835f8611843a8a0514d36230b949fdeb1033506b0b715a42440cd3a4aa5aebf0c6072bb65eb844cea5b116fda3ce60044875c3e2eafbdca22b16511053aea9d87f9579960c16133db6302e2ea8c553eb3501be36619b8708e5e8e1fc5629a49313e6b6c3b4570d458f29127714bb6174710db349ac0ffa0f1f9664069715059d88cc5436132cd614a06bdf21dfc8484e1c075160ab03d60b4a3abd41dcdf928814a6dbc021fcbc597d49f3a66ff5b7d3a515824701240107e0cc03f3c9c4b01548fe4ae79fa91165f7cfbfb06f98db4f4214ecd4ed88b6057fd0a6ec616d7a9a4a1de68eeeb8de6759d5680b58a18eba8e85c0751ff0ce052e645354bb29831d0f17241aa90b7f5a3f90e53e2c159e8d2d5680c21bbc150b5c4b4b740f25bb967eb782addb0677f9d10e142703842ede29708b66515afe0e01dfe1c255fae58be7d29a4bc3fcfaae72dc0a089550e2c28d8717707dd1e80ff18cdcbd7e08f4a0c9ef23852065b3e46c53068515d82f5dfe49c73e64413c090a2743cc2d69c4bb7c61a3512733f0587d8df528b572b17068f8fe09f0dad80bde66807fe9d3b32463f00113573c20e730b972f7759c6521ae5a19b56bc11f07b7022d4f2e892d032ced9a2befd49b0493cd15470b8f5f1383ec016ef035b407886187027b09cf6fd4477bdffa7c9e6b085a87d59f72f52961923908cc41ab09f74c81677cfdb25a37dcf41be2168de6b68200e92f5f42ac8627521aa0e81900031b2d223dafaa06a23897f74211d969481c83f7a5403ed17a78c7652f01e907bfa8da28a075d182b45cb4b3b70d453ca8092aa06bb72728688bf32e83a04e026aa57a47ccb91b93b182bedf611bdfc2866b8a184a2d1a3aec3008a6c6ab20b7a2d1aebf7abc667974435dd74d02aff38d2e706cf84348016a0634116b8e0cae"}}' -H 'Content-Type: application/json'