<p>The problem is on this line: </p>

<pre><code>amount: 100000,
</code></pre>

<p>The amount is supposed to be in coins, not satoshis, according <a href="https://github.com/bitpay/bitcore/blob/master/lib/transaction/transaction.js#L495-L506" rel="nofollow">these comments</a> in the code. To fix it, replace that line with</p>

<pre><code>satoshis: 100000,
</code></pre>

<blockquote>
  <p>And what is the deal with these large numbers:</p>
</blockquote>

<p>Since the code was assuming an input with 100,000 coins in the inputs, the change address had a lot more coins in it than there should have been.</p>

CC BY-SA 3.0
2015-06-22T19:26:28.237Z
2015-06-22T19:26:28.237Z
morsecoder
<p>I am trying to push a raw transaction to blockr.io <strong>testnet</strong> using bitcore (current latest version 0.12.9) for node.js <a href="https://github.com/bitpay/bitcore" rel="nofollow">https://github.com/bitpay/bitcore</a></p>

<p>I have constructed my transaction like so:</p>

<pre><code>var unspents=
[ { txid: '67b22a1874be2e748b2c904e2181f85a9d6503001e58c374e17b1161cd5a36f4',
    vout: 0,
    address: 'myHtNgECiAjBctWz1tM2TN2PupWwfHtgMi',
    scriptPubKey: '76a914c2f9958848c465efd042fcb76fef519f03a83ec288ac',
    amount: 100000,
    confirmations: 39 } ];



    var transaction=new bitcore.Transaction()
    .fee(bitcore.Unit.fromBTC(0.0001).toSatoshis())
    .from(unspents) // there is one unspent of 0.001
    .to(bitcore.Address.fromString(payToAddress),0.001)
    .change(myAddress)
    .sign(privateKey);



console.log(transaction.isFullySigned()); // This returns true
</code></pre>

<p>When I POST this to blockr.io I serialize it:</p>

<pre><code>'https://'+'t'+'btc.blockr.io/api/v1/tx/push'    // &lt; t at the beginning is for testnet

{'hex':transaction.serialize()} // 0100000001f4365acd61117be174c3581e0003659d5af881214e902c8b742ebe74182ab267000000006a47304402204f5950a8f8e7346e96101da811452246d51741131310f58d5cfdc064e547d3dc02202b817a442bb043a1174fe0703082ebbd7bc622afc00084710be21fa143444d83012102bbe798da887604bdd360dd059061b48816634e44d9f54563af2c727b8bcb3e2fffffffff02a08601000000000017a9149ffdff1f3eea0deb21ed967b91c7ef3cce65b2d68750f2704e180900001976a914c2f9958848c465efd042fcb76fef519f03a83ec288ac00000000
</code></pre>

<p>The response I get back from blockr.io is:</p>

<pre><code>[ { status: 'fail',
    data: 'Could not push your transaction!',
    code: 500,
    message: 'Did you sign your transaction?' },
  500 ]
</code></pre>

<p>Below is the transaction I sent but as JSON. I'm thinking there is something wrong with it?</p>

<pre><code>{
"version":1,
"inputs":
[{
    "prevTxId":"67b22a1874be2e748b2c904e2181f85a9d6503001e58c374e17b1161cd5a36f4",
    "outputIndex":0,
    "sequenceNumber":4294967295,
    "script":"47304402204f5950a8f8e7346e96101da811452246d51741131310f58d5cfdc064e547d3dc02202b817a442bb043a1174fe0703082ebbd7bc622afc00084710be21fa143444d83012102bbe798da887604bdd360dd059061b48816634e44d9f54563af2c727b8bcb3e2f",
    "scriptString":"71 0x304402204f5950a8f8e7346e96101da811452246d51741131310f58d5cfdc064e547d3dc02202b817a442bb043a1174fe0703082ebbd7bc622afc00084710be21fa143444d8301 33 0x02bbe798da887604bdd360dd059061b48816634e44d9f54563af2c727b8bcb3e2f",
    "output":{
        "satoshis":10000000000000,
        "script":"76a914c2f9958848c465efd042fcb76fef519f03a83ec288ac"
    }
}]
,"outputs":
[{
    "satoshis":100000,
    "script":"a9149ffdff1f3eea0deb21ed967b91c7ef3cce65b2d687"
},{
    "satoshis":9999999890000,
    "script":"76a914c2f9958848c465efd042fcb76fef519f03a83ec288ac"
}]
,"nLockTime":0,
"changeScript":"OP_DUP OP_HASH160 20 0xc2f9958848c465efd042fcb76fef519f03a83ec2 OP_EQUALVERIFY OP_CHECKSIG",
"changeIndex":1,
"fee":10000
</code></pre>

<p>}</p>

<p>I signed it with my private key then serialized it as blockr wants it in hex format does this mean I have got to somehow sign it after it's serialized or what?</p>

<p>And what is the deal with these large numbers:</p>

<pre><code>"satoshis":10000000000000,

"satoshis":9999999890000,
</code></pre>

<p><strong>UPDATE:</strong></p>

<p>Block chain info instead returns this error:</p>

<pre><code>Unable To find all tx inputs [67b22a1874be2e748b2c904e2181f85a9d6503001e58c374e17b1161cd5a36f4]
</code></pre>

<raw-transaction><bitcore>
Bitcore.io Create a raw tx hex (signed) to push to the blockchain
Ben Muircroft
# Bitcore.io Create a raw tx hex (signed) to push to the blockchain

(Asked by: username_0 on 2015-06-22)

I am trying to push a raw transaction to blockr.io **testnet** using bitcore (current latest version 0.12.9) for node.js <https://github.com/bitpay/bitcore>

I have constructed my transaction like so:

```
var unspents=
[ { txid: '67b22a1874be2e748b2c904e2181f85a9d6503001e58c374e17b1161cd5a36f4',
    vout: 0,
    address: 'myHtNgECiAjBctWz1tM2TN2PupWwfHtgMi',
    scriptPubKey: '76a914c2f9958848c465efd042fcb76fef519f03a83ec288ac',
    amount: 100000,
    confirmations: 39 } ];

    var transaction=new bitcore.Transaction()
    .fee(bitcore.Unit.fromBTC(0.0001).toSatoshis())
    .from(unspents) // there is one unspent of 0.001
    .to(bitcore.Address.fromString(payToAddress),0.001)
    .change(myAddress)
    .sign(privateKey);

console.log(transaction.isFullySigned()); // This returns true

```

When I POST this to blockr.io I serialize it:

```
'https://'+'t'+'btc.blockr.io/api/v1/tx/push'    // < t at the beginning is for testnet

{'hex':transaction.serialize()} // 0100000001f4365acd61117be174c3581e0003659d5af881214e902c8b742ebe74182ab267000000006a47304402204f5950a8f8e7346e96101da811452246d51741131310f58d5cfdc064e547d3dc02202b817a442bb043a1174fe0703082ebbd7bc622afc00084710be21fa143444d83012102bbe798da887604bdd360dd059061b48816634e44d9f54563af2c727b8bcb3e2fffffffff02a08601000000000017a9149ffdff1f3eea0deb21ed967b91c7ef3cce65b2d68750f2704e180900001976a914c2f9958848c465efd042fcb76fef519f03a83ec288ac00000000

```

The response I get back from blockr.io is:

```
[ { status: 'fail',
    data: 'Could not push your transaction!',
    code: 500,
    message: 'Did you sign your transaction?' },
  500 ]

```

Below is the transaction I sent but as JSON. I'm thinking there is something wrong with it?

```
{
"version":1,
"inputs":
[{
    "prevTxId":"67b22a1874be2e748b2c904e2181f85a9d6503001e58c374e17b1161cd5a36f4",
    "outputIndex":0,
    "sequenceNumber":4294967295,
    "script":"47304402204f5950a8f8e7346e96101da811452246d51741131310f58d5cfdc064e547d3dc02202b817a442bb043a1174fe0703082ebbd7bc622afc00084710be21fa143444d83012102bbe798da887604bdd360dd059061b48816634e44d9f54563af2c727b8bcb3e2f",
    "scriptString":"71 0x304402204f5950a8f8e7346e96101da811452246d51741131310f58d5cfdc064e547d3dc02202b817a442bb043a1174fe0703082ebbd7bc622afc00084710be21fa143444d8301 33 0x02bbe798da887604bdd360dd059061b48816634e44d9f54563af2c727b8bcb3e2f",
    "output":{
        "satoshis":10000000000000,
        "script":"76a914c2f9958848c465efd042fcb76fef519f03a83ec288ac"
    }
}]
,"outputs":
[{
    "satoshis":100000,
    "script":"a9149ffdff1f3eea0deb21ed967b91c7ef3cce65b2d687"
},{
    "satoshis":9999999890000,
    "script":"76a914c2f9958848c465efd042fcb76fef519f03a83ec288ac"
}]
,"nLockTime":0,
"changeScript":"OP_DUP OP_HASH160 20 0xc2f9958848c465efd042fcb76fef519f03a83ec2 OP_EQUALVERIFY OP_CHECKSIG",
"changeIndex":1,
"fee":10000

```

}

I signed it with my private key then serialized it as blockr wants it in hex format does this mean I have got to somehow sign it after it's serialized or what?

And what is the deal with these large numbers:

```
"satoshis":10000000000000,

"satoshis":9999999890000,

```

**UPDATE:**

Block chain info instead returns this error:

```
Unable To find all tx inputs [67b22a1874be2e748b2c904e2181f85a9d6503001e58c374e17b1161cd5a36f4]

```

**Tags:** raw-transaction, bitcore


---

## 1 answers

### Answer by username_1 on 2015-06-22. Score: 2 | Accepted answer

The problem is on this line:

```
amount: 100000,

```

The amount is supposed to be in coins, not satoshis, according [these comments](https://github.com/bitpay/bitcore/blob/master/lib/transaction/transaction.js#L495-L506) in the code. To fix it, replace that line with

```
satoshis: 100000,

```

> And what is the deal with these large numbers:

Since the code was assuming an input with 100,000 coins in the inputs, the change address had a lot more coins in it than there should have been.


---

