Sendrawtransaction not working

Hi,
I try to send raw transaction with curl:

curl --user kzv:pass  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendrawtransaction", "params": ["010000006a190e57019f9d0cca16ff2ee34efa067ae8850d8b8430caf84ab74eb2d2b52ea9cedc1af2010000006a47304402205da573c2d220e4e3aa87e5a960d47fb9cf334a8d32d18ed5654c493cccd6cd6b02203468e7211fdcf0258a992c05c8905773b54e04b2a3ee22e701f2e450c4e6e3c40121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561faffffffff0280969800000000001976a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac00127a00000000001976a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac00000000"] }' -H 'content-type: text/plain;' http://127.0.0.1:9902/

got responce:

{"result":"2af6ca60a4602d4848f76d706eb2acd2d37aa7d4171267c559a5c37798f3dde2","error":null,"id":"curltest"}

but the transaction does not fall into the network
https://bkchain.org/ppc/search?search=2af6ca60a4602d4848f76d706eb2acd2d37aa7d4171267c559a5c37798f3dde2

What is wrong with this transaction?

1 Like

Output sum is bigger than input sum.

The transaction is successfully broadcasted, but all receiving nodes will discard it.

The transaction input only holds 0.21PPC (http://ppc.blockr.io/tx/info/f21adccea92eb5d2b24eb74af8ca30848b0d85e87a06fa4ee32eff16ca0c9d9f)
While the outputs sum to 18PPC.

[quote=“hrobeers, post:2, topic:3843”]Output sum is bigger than input sum.

The transaction is successfully broadcasted, but all receiving nodes will discard it.

The transaction input only holds 0.21PPC (http://ppc.blockr.io/tx/info/f21adccea92eb5d2b24eb74af8ca30848b0d85e87a06fa4ee32eff16ca0c9d9f)
While the outputs sum to 18PPC.[/quote]

Thank you very match!

I understand where the error!

still not working

 curl --user kzv:pass  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendrawtransaction", "params": ["01000000e42a0e57019f9d0cca16ff2ee34efa067ae8850d8b8430caf84ab74eb2d2b52ea9cedc1af2010000006b4830450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f0121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561faffffffff02a0860100000000001976a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac905f0100000000001976a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac00000000"] }' -H 'content-type: text/plain;' http://127.0.0.1:9902/

result

{"result":"02fa4bcd9f074e42a9e6b66ab588116b503392ef6e5558e40a5d21b5e9d3e3dc","error":null,"id":"curltest"}

Input 0.2 PPC
Output 0.19 PPC

“Search failed, could not find anything!”
https://bkchain.org/ppc/search?search=02fa4bcd9f074e42a9e6b66ab588116b503392ef6e5558e40a5d21b5e9d3e3dc

Did you sign the transaction using “signrawtransaction”?

I sign transaction with bitcoinjs library https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction_builder.js#L405

Why are you using curl instead of a regular wallet to send a transaction?

Are you planning to load test the live network with automated scripts? If so, please do not do that…

Here is your error:

ERROR: ConnectInputs() : 02fa4bcd9f VerifySignature failed ERROR: CTxMemPool::accept() : ConnectInputs failed 02fa4bcd9f

You can find it in ~/.ppcoin/debug.log after executing the command below in the ppcoin client.

sendrawtransaction 01000000e42a0e57019f9d0cca16ff2ee34efa067ae8850d8b8430caf84ab74eb2d2b52ea9cedc1af2010000006b4830450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f0121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561faffffffff02a0860100000000001976a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac905f0100000000001976a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac00000000 1

Note the second parameter “1”, this will force the client to validate the transaction before broadcasting it to the network. Otherwise the client will keep sending it to peers.

[quote=“ppcman, post:7, topic:3843”]Why are you using curl instead of a regular wallet to send a transaction?

Are you planning to load test the live network with automated scripts? If so, please do not do that…[/quote]

I develop in-browser wallet https://multicoins.org and i want to add peercoin to it.
Now it remains to understand what the difference between bitcoin and peercoin raw transaction.

[quote=“hrobeers, post:8, topic:3843”]Here is your error:

ERROR: ConnectInputs() : 02fa4bcd9f VerifySignature failed ERROR: CTxMemPool::accept() : ConnectInputs failed 02fa4bcd9f

You can find it in ~/.ppcoin/debug.log after executing the command below in the ppcoin client.

sendrawtransaction 01000000e42a0e57019f9d0cca16ff2ee34efa067ae8850d8b8430caf84ab74eb2d2b52ea9cedc1af2010000006b4830450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f0121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561faffffffff02a0860100000000001976a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac905f0100000000001976a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac00000000 1

Note the second parameter “1”, this will force the client to validate the transaction before broadcasting it to the network. Otherwise the client will keep sending it to peers.[/quote]

Thank you again. It seems that signature transactions in bitcoin differs from peercoin one. :frowning:

We should encourage the support of peercoin in any wallet.

If you point me to the code that signs the transactions, I’ll look into the peercoin code what the difference is.
Peercoin should work quite similar to bitcoin tough.

[quote=“hrobeers, post:10, topic:3843”]We should encourage the support of peercoin in any wallet.

If you point me to the code that signs the transactions, I’ll look into the peercoin code what the difference is.
Peercoin should work quite similar to bitcoin tough.[/quote]

My wallet is opensource and use bitcoinjs-lib.
My code for transaction: https://github.com/3s3s/multicoins.org/blob/master/server_side/sendTransaction.js#L181

My code call library function: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction_builder.js#L405
Inside this function, signing itself occurs here: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction_builder.js#L479
In this place function call another final function: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction.js#L174

[code]Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashType) {
typeforce(types.tuple(types.UInt32, types.Buffer, /* types.UInt8 */ types.Number), arguments)

// https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L29
if (inIndex >= this.ins.length) return ONE

var txTmp = this.clone()

// in case concatenating two scripts ends up with two codeseparators,
// or an extra one at the end, this prevents all those possible incompatibilities.
var hashScript = bscript.compile(bscript.decompile(prevOutScript).filter(function (x) {
return x !== opcodes.OP_CODESEPARATOR
}))
var i

// blank out other inputs’ signatures
txTmp.ins.forEach(function (input) { input.script = EMPTY_SCRIPT })
txTmp.ins[inIndex].script = hashScript

// blank out some of the inputs
if ((hashType & 0x1f) === Transaction.SIGHASH_NONE) {
// wildcard payee
txTmp.outs = []

// let the others update at will
txTmp.ins.forEach(function (input, i) {
  if (i !== inIndex) {
    input.sequence = 0
  }
})

} else if ((hashType & 0x1f) === Transaction.SIGHASH_SINGLE) {
var nOut = inIndex

// only lock-in the txOut payee at same index as txIn
// https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L60
if (nOut >= this.outs.length) return ONE

txTmp.outs = txTmp.outs.slice(0, nOut + 1)

// blank all other outputs (clear scriptPubKey, value === -1)
var stubOut = {
  script: EMPTY_SCRIPT,
  valueBuffer: VALUE_UINT64_MAX
}

for (i = 0; i < nOut; i++) {
  txTmp.outs[i] = stubOut
}

// let the others update at will
txTmp.ins.forEach(function (input, i) {
  if (i !== inIndex) {
    input.sequence = 0
  }
})

}

// blank out other inputs completely, not recommended for open transactions
if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
txTmp.ins[0] = txTmp.ins[inIndex]
txTmp.ins = txTmp.ins.slice(0, 1)
}

// serialize and hash
var buffer = new Buffer(txTmp.byteLength() + 4)
buffer.writeInt32LE(hashType, buffer.length - 4)
txTmp.toBuffer().copy(buffer, 0)

return bcrypto.hash256(buffer)
}[/code]

I see more…
Transaction hash signed with this code:

[code]
ECPair.prototype.sign = function (hash) {
if (!this.d) throw new Error(‘Missing private key’)

return ecdsa.sign(hash, this.d)
}[/code]

this.d =

You are signing the transactions server side?
You seem to be storing and decrypting the private keys server side.

I do not support this practice.

However, I like where you are going with this. Creating a thin client wallet using a block explorer’s API.
Do you know of similar thin clients that use block explorer API’s?
I’d advise on getting the transaction signing client side so that the private keys are only known client side, and then I’m willing to take a look at it again.

[quote=“hrobeers, post:14, topic:3843”]However, I like where you are going with this. Creating a thin client wallet using a block explorer’s API.
Do you know of similar thin clients that use block explorer API’s?
I’d advise on getting the transaction signing client side so that the private keys are only known client side, and then I’m willing to take a look at it again.

And please add a license file to your project so that we know our rights.[/quote]

All private keys are stored in browser cashe only and not sending to the server at all. User may encode his wallet and backup it to the server.
Signing, encoding and decoding are occurs at client side.
You can go to https://multicoins.org then disable the internet connection and then sign (or verify) any message (menu “Tools”) and it will work!
The same with transactions: its signed on the client side and then sending to the server in raw form.

So why is this code then in the server_side folder? https://github.com/3s3s/multicoins.org/blob/master/server_side/sendTransaction.js#L181
Because indeed it looks like client side code as it’s in a button click event handler.
Edit: This are probably all node.js things that I’m not getting yet.

I’ll check it out soon then, I like the wallet idea very much.
So I’ll get back to you, great work!

This is for my convenience only: i write modules in the “server_side” folder, and then “compile” all of them to the one file “wallet.js”.

Thank you for your time and good feedback!

Here s my 2 satohis:

I was not aware that bitcoinjs supports peercoin. But if it does, hooray!

What peercoin differs from bitcoin is that it has an extra timestamp (4 bytes) in its transaction:

https://wiki.peercointalk.org/index.php?title=Transactions

so unless there s code that deals with that difference…

[quote=“thehuntergames, post:18, topic:3843”]Here s my 2 satohis:

I was not aware that bitcoinjs supports peercoin. But if it does, hooray!

What peercoin differs from bitcoin is that it has an extra timestamp (4 bytes) in its transaction:

https://wiki.peercointalk.org/index.php?title=Transactions

so unless there s code that deals with that difference…[/quote]

bitcoinjs is not support peercoin, but i have made some changes. In beta-version my wallet is already support peercoin and left to do only support for transaction sending.

You can see the beta-version at https://multicoins-kzv.c9users.io (the link will be available for a couple of hours)

I ve just made a fork with the sole purpose of having a peercoinjs.

So far I adjusted only a few files: network,transaction and transactionbuilder.

I’ll soon start adjusting some test files to see if i can create a raw tx for peercoin. I cant think of why signing a tx should be any different than in bitcoin