Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendRawTransaction #5

Open
Jimweb3 opened this issue May 22, 2021 · 6 comments
Open

SendRawTransaction #5

Jimweb3 opened this issue May 22, 2021 · 6 comments

Comments

@Jimweb3
Copy link

Jimweb3 commented May 22, 2021

SendRawTransaction return error "Amount is not a number or string"

I can Send with node use hex

@ordishs
Copy link
Owner

ordishs commented May 22, 2021

I can take a look if you send me more details and an example.

@Jimweb3
Copy link
Author

Jimweb3 commented May 23, 2021

Thank you for your reply,

No matter I use the txHex that has been broadcasted or the txHex that has not been broadcasted, the same error Amount is not a number or string is returned

client, err := bitcoin.New("115.28.105.169", 28332, "abc", "123456", false) txId,err:=client.SendRawTransaction("0100000002b212995825c72d1abf5505a3017694f564dda29908fe5d45ab45b6a3e1748ca5010000006a473044022030d77fbaf3ec092a5038e7fc0235bb2126ca5099dccac5383d58cea01a8d329302207581678aa91743abe31c4cf54e16b0c58e05631d20ccde33be242d96cb57ff1141210373b675c91c95391b6d7977de12bf081bae193470aa0199efc1f847d799497b67ffffffff428947c3e5fb13faf1e71ea86b209b88c3b2e1cd77b326b696fc6e9fb3d0ced6000000006b483045022100801a316894dc40d1e335a14d25b6a7b5b72691b0842878105942d86303a09e1502204d737aecf5d1972e880e329363681bb7c97334e262cf4a20293fee3d8ca87d7041210373b675c91c95391b6d7977de12bf081bae193470aa0199efc1f847d799497b67ffffffff030a1a0000000000001976a914dc9ad4971a54b52308fa3c958df73eac52fb552f88acc6160000000000001976a914a933500e7326f81a974d4212aa16ae29f92e257188ac00000000000000003d6a3b53656e642076696120612057656368617420626f74206d616465206279206161726f6e363720687474703a2f2f6269742e6c792f333331536d754300000000")

bitcointest network.

@Jimweb3
Copy link
Author

Jimweb3 commented May 23, 2021

Hi,is there param error ?

I try this code :

new a client by your code and call sendrawtransaction only one param txHex , then it work.

myClients, err := NewClient("115.28.105.169", 28332, "abc", "123456", false) r, err := myClients.call("sendrawtransaction", []interface{}{txHex})

@ordishs
Copy link
Owner

ordishs commented May 23, 2021

Your transaction works fine for me with the following code:

func TestSendRawTransaction2(t *testing.T) {
b, err := New("localhost", 8332, "bitcoin", "bitcoin", false)
if err != nil {
t.Fatal(err)
}

res, err := b.SendRawTransaction("0100000002b212995825c72d1abf5505a3017694f564dda29908fe5d45ab45b6a3e1748ca5010000006a473044022030d77fbaf3ec092a5038e7fc0235bb2126ca5099dccac5383d58cea01a8d329302207581678aa91743abe31c4cf54e16b0c58e05631d20ccde33be242d96cb57ff1141210373b675c91c95391b6d7977de12bf081bae193470aa0199efc1f847d799497b67ffffffff428947c3e5fb13faf1e71ea86b209b88c3b2e1cd77b326b696fc6e9fb3d0ced6000000006b483045022100801a316894dc40d1e335a14d25b6a7b5b72691b0842878105942d86303a09e1502204d737aecf5d1972e880e329363681bb7c97334e262cf4a20293fee3d8ca87d7041210373b675c91c95391b6d7977de12bf081bae193470aa0199efc1f847d799497b67ffffffff030a1a0000000000001976a914dc9ad4971a54b52308fa3c958df73eac52fb552f88acc6160000000000001976a914a933500e7326f81a974d4212aa16ae29f92e257188ac00000000000000003d6a3b53656e642076696120612057656368617420626f74206d616465206279206161726f6e363720687474703a2f2f6269742e6c792f333331536d754300000000")
if err != nil {
	t.Error(err)
	t.FailNow()
}
t.Logf("%s", res)

}

The "Missing inputs" error is being returned from the call when you point to Testnet, because the inputs are on the Mainnet network, not Testnet.

@Jimweb3
Copy link
Author

Jimweb3 commented May 24, 2021

Thank you for your reply , Sorry give you error txHex,

This txHex below has been sent to the network,when try send again , will return "Transaction already in block chain", but now return "Amount is not a number or string"

0100000001568a46bc77af3a7f703adfc3b55639fcde3593f952f84578606be5e1c522b07e000000006b4830450221009398f1165ca630411231669dd621cb7c711cd1942a9810b7754272671ef7b70002200cbaf4e66b381de37b51dc0a1f8cda48adae43024b84d66c0da1383eff8283e2812103a04366dec11b005e510cd3556fe5621d0d165989c70edcb4a3763cbc0fac968cffffffff027f7b0d00000000001976a914b6fcc6a9f87d8ec8e49688d30486bc5dab9a9c8b88ac02000000000000001976a9142a53015be0bec88b51ac83be816b93597a17780d88ac00000000

if I send this txHex with only one param txHex not txHex,true,can return "Transaction already in block chain"

r, err := b.call("sendrawtransaction", []interface{}{hex}) works fine , return Transaction already in block chain
r, err := b.call("sendrawtransaction", []interface{}{hex, true}) return Amount is not a number or string

@opticoder
Copy link

The reason of "Amount is not a number or string" error is that type of the second param of sendrawtransaction method was changed in the modern versions of bitcoind.
Was: https://bitcoincore.org/en/doc/0.16.0/rpc/rawtransactions/sendrawtransaction/
Now: https://developer.bitcoin.org/reference/rpc/sendrawtransaction.html
It's meaning was https://bitcoin.stackexchange.com/a/59127 and now it's self-descriptive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants