<p>the first (but not the last) error is:</p>

<p>your utxo <a href="https://blockchain.info/tx/3fe18d12ff763721c52cbce429fe92362c7dab65f42402f428690c4e0d87c1b4" rel="nofollow">3fe1...1b4:0</a> has 3000 satoshi but the sum of your outputs is 6000 satoshi</p>

CC BY-SA 3.0
2016-06-10T11:26:55.597Z
Nice spotting! I have now reduced each to 1000 and now get no error from blockr but instead get....

Your transaction id is: 801d6fb0cbf920831973a3888f57fcac1fa76ba1642c804d94d3b213522dacd2
Will-In-China
CC BY-SA 3.0
2016-06-10T11:32:41.000Z
and looking it up here http://webbtc.com/tx/801d6fb0cbf920831973a3888f57fcac1fa76ba1642c804d94d3b213522dacd2.json says it cant be found
Will-In-China
CC BY-SA 3.0
2016-06-10T11:44:03.427Z
(1) webbtc does not show unconfirmed transactions (2) the fee for your transaction is very small (3) the output values of 1000 satoshi are 'dust' (4) blockchain.info does not accept/show unconfirmed transactions with op_return scriptsigs.... aaaaaand everything else is quite fine! your transaction is valid!
amaclin
CC BY-SA 3.0
2016-06-10T11:50:26.950Z
1) I just need to wait for confirmation?
2) The transaction is small and i guess I will need to wait a long time? how long?
3) 1000 satoshi is commonly called "Dust" thank you and well noted.
4) blockchain.info I wont be using anymore
Will-In-China
CC BY-SA 3.0
2016-06-10T12:01:03.277Z
(1) it depends of your goal. usually I do not wait or even think about such small values (2) may be a hour, may be a day, may be a year (3) there is no consensus value for "dust". (4) up to you
amaclin
CC BY-SA 3.0
2016-06-10T12:24:29.917Z
Checking the below link it indicates that I should be paying 50-80 Satoshi per byte to get "Block 1". 1) What is "Block 1", "Block 2" etc  2) How fast could I expect block 1 to confirm?  3) 250 byte transaction x 80 Satoshi is 20,000 Satoshi and today that 0.11 USD is that right?
http://p2sh.info/dashboard/db/fee-estimation
Will-In-China
CC BY-SA 3.0
2016-06-10T12:30:38.223Z
80 satoshi per byte is too big for testing. 10 satoshi per byte or even 5 satoshi per byte is quite enough nowadays
amaclin
CC BY-SA 3.0
2016-06-10T11:22:08.043Z
2016-06-10T11:22:08.043Z
amaclin
<p>So the below is the function I'm running. I'm sending in the key for this bitcoin address </p>

<pre><code>16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W
</code></pre>

<p>and the message</p>

<pre><code>bkawk
</code></pre>

<p>to this function</p>

<pre><code>// Require the packages that we need.

var bitcoin = require('bitcoinjs-lib');
var request = require('request');
var blockchain = require('blockchain.info');
var blockexplorer = require('blockchain.info/blockexplorer');


// Export the module and pass in the message and the WIF
exports.opReturn = function (message, WIF) {

// Setup the new promise
return new Promise(function(resolve, reject) {    

// Set the network to the main net not test
    var network = bitcoin.networks.mainnet;

 // Generate the keypair
    var keyPair = bitcoin.ECPair.fromWIF(WIF);

// Get the address from the key pair
    var address = keyPair.getAddress();

// Ask blockchain.info for all the unspent transactions 
    var url = 'https://blockchain.info/id/unspent?active='+address;
    request(url, function (error, response, body) {

// Check the request didn't error and we got a 200 ok back
        if (!error &amp;&amp; response.statusCode == 200) {

// Parse the results
            var body = JSON.parse(body);


// Build a new transaction
            var tx = new bitcoin.TransactionBuilder(network);
</code></pre>

<p>cont...</p>

<pre><code>// Buffer the message into hex
            var data = new Buffer(message);

// Prepare the message
            var dataScript = bitcoin.script.nullDataOutput(data);

// I Suspect there is problems here!!
            var unspent = body.unspent_outputs[0].tx_hash_big_endian;

// Add the unspent tx to the output                
            tx.addInput(unspent, 0);

// Add the unspent transaction to the first output              
            tx.addOutput(dataScript, 0);

// Add our address to the 1st output - Must I use another address or no?
            tx.addOutput(address, 1000);

// Add our address to the 2nd output - Must I use another address here too?
            tx.addOutput(address, 1000);

// Sign the transaction
            tx.sign(0, keyPair);

// Convert to hex
            var txRaw = tx.build().toHex();

            var txId = txRaw.getId()
            console.log(txId);

// Resolve the promise
            resolve(txRaw);

// Log the hex
            console.log(txRaw.toHex());
        } else{

// if there was an error reject the promise
            reject(error);
        };
    })

}); //-- END PROMISE
};// END FUNCTION
</code></pre>

<p>the above console.log is giving me this transaction hex</p>

<pre><code>0100000001b4c1870d4e0c6928f40224f465ab7d2c3692fe29e4bc2cc5213776ff128de13f000000006b483045022100a954cdb05753fed2f8afc41619d66dde45e330b1aa75cd5a1d1a03b67392642702203bda25690dac67bed0117fd28ad30fc2cbc16aa778a3b37832aabba9939e344001210298e836ce7df5696bdce02742bb5d7a070b2e5b1ab3535001b71f3615c21c1b1dffffffff030000000000000000076a05626b61776bb80b0000000000001976a9143c5d9d2466274014c2db74dd4738116a193d142788acb80b0000000000001976a9143c5d9d2466274014c2db74dd4738116a193d142788ac00000000
</code></pre>

<p>which decoded looks like this</p>

<pre><code>        {
        "lock_time":0,
        "size":242,
        "inputs":[
            {
                "prev_out":{
                    "index":0,
                    "hash":"3fe18d12ff763721c52cbce429fe92362c7dab65f42402f428690c4e0d87c1b4"
                },
                "script":"483045022100a954cdb05753fed2f8afc41619d66dde45e330b1aa75cd5a1d1a03b67392642702203bda25690dac67bed0117fd28ad30fc2cbc16aa778a3b37832aabba9939e344001210298e836ce7df5696bdce02742bb5d7a070b2e5b1ab3535001b71f3615c21c1b1d"
            }
        ],
        "version":1,
        "vin_sz":1,
        "hash":"926eeecb1fc28a34cb8ed14e1e6175ec9012af390b232e26d3c610c345abba47",
        "vout_sz":3,
        "out":[
            {
                "script_string":"OP_RETURN 626b61776b",
                "value":0,
                "script":"6a05626b61776b"
            },
            {
                "script_string":"OP_DUP OP_HASH160 3c5d9d2466274014c2db74dd4738116a193d1427 OP_EQUALVERIFY OP_CHECKSIG",
                "address":"16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W",
                "value":3000,
                "script":"76a9143c5d9d2466274014c2db74dd4738116a193d142788ac"
            },
            {
                "script_string":"OP_DUP OP_HASH160 3c5d9d2466274014c2db74dd4738116a193d1427 OP_EQUALVERIFY OP_CHECKSIG",
                "address":"16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W",
                "value":3000,
                "script":"76a9143c5d9d2466274014c2db74dd4738116a193d142788ac"
            }
        ]
        }
</code></pre>

<p>Pushing it to <a href="https://blockchain.info/pushtx" rel="nofollow">https://blockchain.info/pushtx</a> returns...</p>

<pre><code>None Standard Script Output OP_RETURN 626b61776b
</code></pre>

<p>And pushing here <a href="http://blockr.io/tx/push" rel="nofollow">http://blockr.io/tx/push</a> results in </p>

<pre><code>There was an error pushing your transaction to network!

Did you sign your transaction? Is this double spend? Have you already sent this transaction?
</code></pre>

<p>but then when I check it here I don't see the transaction. Any Ideas?</p>

<p><a href="https://blockchain.info/address/16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W" rel="nofollow">https://blockchain.info/address/16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W</a></p>

<p>Here is an example of a successful transaction made from Colu</p>

<p><a href="https://blockchain.info/tx/d831fa05d6bbb2e939e42764945936ee7c23b96a46c173c9e8647d9fe4f0d485?show_adv=true" rel="nofollow">https://blockchain.info/tx/d831fa05d6bbb2e939e42764945936ee7c23b96a46c173c9e8647d9fe4f0d485?show_adv=true</a> </p>

CC BY-SA 3.0
2016-06-10T13:43:02.203Z
You should probably edit the title to be the actual question, rather than the question's general topic.  It would also be nice if the question itself was a little more specific, rather than just "here's my code, tell me what's wrong".  Narrow your question down to a specific, identified problem, and you are more likely to get better answers.
Jestin
CC BY-SA 3.0
2016-06-10T13:52:13.513Z
Thank you @jestin for the kind suggestion, the answer to the problem was unknown at the time of writing and as you can see I detailed the issue and where I thought the problems may be as best as I could. Please can you make a suggestions for the better title?
Will-In-China
CC BY-SA 3.0
2016-06-10T14:00:01.477Z
Something like "Invalid transaction created with bitcoinjs-lib" might be better.  I don't think you had any reason to believe the Promise was the problem, since you were obviously resolving the raw transaction.  That word just made it confusing which part you were asking about.
Jestin
<blockchain.info><bitcoinjs>
OP_RETURN Promise with bitcoinjs-lib v2.2.0 and blockchain.info
Will-In-China
# OP_RETURN Promise with bitcoinjs-lib v2.2.0 and blockchain.info

(Asked by: username_0 on 2016-06-10)

So the below is the function I'm running. I'm sending in the key for this bitcoin address

```
16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W

```

and the message

```
bkawk

```

to this function

```
// Require the packages that we need.

var bitcoin = require('bitcoinjs-lib');
var request = require('request');
var blockchain = require('blockchain.info');
var blockexplorer = require('blockchain.info/blockexplorer');

// Export the module and pass in the message and the WIF
exports.opReturn = function (message, WIF) {

// Setup the new promise
return new Promise(function(resolve, reject) {    

// Set the network to the main net not test
    var network = bitcoin.networks.mainnet;

 // Generate the keypair
    var keyPair = bitcoin.ECPair.fromWIF(WIF);

// Get the address from the key pair
    var address = keyPair.getAddress();

// Ask blockchain.info for all the unspent transactions 
    var url = 'https://blockchain.info/id/unspent?active='+address;
    request(url, function (error, response, body) {

// Check the request didn't error and we got a 200 ok back
        if (!error && response.statusCode == 200) {

// Parse the results
            var body = JSON.parse(body);

// Build a new transaction
            var tx = new bitcoin.TransactionBuilder(network);

```

cont...

```
// Buffer the message into hex
            var data = new Buffer(message);

// Prepare the message
            var dataScript = bitcoin.script.nullDataOutput(data);

// I Suspect there is problems here!!
            var unspent = body.unspent_outputs[0].tx_hash_big_endian;

// Add the unspent tx to the output                
            tx.addInput(unspent, 0);

// Add the unspent transaction to the first output              
            tx.addOutput(dataScript, 0);

// Add our address to the 1st output - Must I use another address or no?
            tx.addOutput(address, 1000);

// Add our address to the 2nd output - Must I use another address here too?
            tx.addOutput(address, 1000);

// Sign the transaction
            tx.sign(0, keyPair);

// Convert to hex
            var txRaw = tx.build().toHex();

            var txId = txRaw.getId()
            console.log(txId);

// Resolve the promise
            resolve(txRaw);

// Log the hex
            console.log(txRaw.toHex());
        } else{

// if there was an error reject the promise
            reject(error);
        };
    })

}); //-- END PROMISE
};// END FUNCTION

```

the above console.log is giving me this transaction hex

```
0100000001b4c1870d4e0c6928f40224f465ab7d2c3692fe29e4bc2cc5213776ff128de13f000000006b483045022100a954cdb05753fed2f8afc41619d66dde45e330b1aa75cd5a1d1a03b67392642702203bda25690dac67bed0117fd28ad30fc2cbc16aa778a3b37832aabba9939e344001210298e836ce7df5696bdce02742bb5d7a070b2e5b1ab3535001b71f3615c21c1b1dffffffff030000000000000000076a05626b61776bb80b0000000000001976a9143c5d9d2466274014c2db74dd4738116a193d142788acb80b0000000000001976a9143c5d9d2466274014c2db74dd4738116a193d142788ac00000000

```

which decoded looks like this

```
        {
        "lock_time":0,
        "size":242,
        "inputs":[
            {
                "prev_out":{
                    "index":0,
                    "hash":"3fe18d12ff763721c52cbce429fe92362c7dab65f42402f428690c4e0d87c1b4"
                },
                "script":"483045022100a954cdb05753fed2f8afc41619d66dde45e330b1aa75cd5a1d1a03b67392642702203bda25690dac67bed0117fd28ad30fc2cbc16aa778a3b37832aabba9939e344001210298e836ce7df5696bdce02742bb5d7a070b2e5b1ab3535001b71f3615c21c1b1d"
            }
        ],
        "version":1,
        "vin_sz":1,
        "hash":"926eeecb1fc28a34cb8ed14e1e6175ec9012af390b232e26d3c610c345abba47",
        "vout_sz":3,
        "out":[
            {
                "script_string":"OP_RETURN 626b61776b",
                "value":0,
                "script":"6a05626b61776b"
            },
            {
                "script_string":"OP_DUP OP_HASH160 3c5d9d2466274014c2db74dd4738116a193d1427 OP_EQUALVERIFY OP_CHECKSIG",
                "address":"16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W",
                "value":3000,
                "script":"76a9143c5d9d2466274014c2db74dd4738116a193d142788ac"
            },
            {
                "script_string":"OP_DUP OP_HASH160 3c5d9d2466274014c2db74dd4738116a193d1427 OP_EQUALVERIFY OP_CHECKSIG",
                "address":"16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W",
                "value":3000,
                "script":"76a9143c5d9d2466274014c2db74dd4738116a193d142788ac"
            }
        ]
        }

```

Pushing it to <https://blockchain.info/pushtx> returns...

```
None Standard Script Output OP_RETURN 626b61776b

```

And pushing here <http://blockr.io/tx/push> results in

```
There was an error pushing your transaction to network!

Did you sign your transaction? Is this double spend? Have you already sent this transaction?

```

but then when I check it here I don't see the transaction. Any Ideas?

<https://blockchain.info/address/16WBguy6KVyTGnF4KX7Vmdx8ztj4wENh4W>

Here is an example of a successful transaction made from Colu

<https://blockchain.info/tx/d831fa05d6bbb2e939e42764945936ee7c23b96a46c173c9e8647d9fe4f0d485?show_adv=true>

**Tags:** blockchain.info, bitcoinjs

> **Comments:**
> **username_1**: You should probably edit the title to be the actual question, rather than the question's general topic.  It would also be nice if the question itself was a little more specific, rather than just "here's my code, tell me what's wrong".  Narrow your question down to a specific, identified problem, and you are more likely to get better answers.  
> **username_0**: Thank you @username_1 for the kind suggestion, the answer to the problem was unknown at the time of writing and as you can see I detailed the issue and where I thought the problems may be as best as I could. Please can you make a suggestions for the better title?  
> **username_1**: Something like "Invalid transaction created with bitcoinjs-lib" might be better.  I don't think you had any reason to believe the Promise was the problem, since you were obviously resolving the raw transaction.  That word just made it confusing which part you were asking about.  

---

## 1 answers

### Answer by username_2 on 2016-06-10. Score: 0 | Accepted answer

the first (but not the last) error is:

your utxo [3fe1...1b4:0](https://blockchain.info/tx/3fe18d12ff763721c52cbce429fe92362c7dab65f42402f428690c4e0d87c1b4) has 3000 satoshi but the sum of your outputs is 6000 satoshi

> **Comments:**
> **username_0**: Nice spotting! I have now reduced each to 1000 and now get no error from blockr but instead get....  Your transaction id is: 801d6fb0cbf920831973a3888f57fcac1fa76ba1642c804d94d3b213522dacd2  
> **username_0**: and looking it up here http://webbtc.com/tx/801d6fb0cbf920831973a3888f57fcac1fa76ba1642c804d94d3b213522dacd2.json says it cant be found  
> **username_2**: (1) webbtc does not show unconfirmed transactions (2) the fee for your transaction is very small (3) the output values of 1000 satoshi are 'dust' (4) blockchain.info does not accept/show unconfirmed transactions with op_return scriptsigs.... aaaaaand everything else is quite fine! your transaction is valid!  
> **username_0**: 1) I just need to wait for confirmation? 2) The transaction is small and i guess I will need to wait a long time? how long? 3) 1000 satoshi is commonly called "Dust" thank you and well noted. 4) blockchain.info I wont be using anymore  
> **username_2**: (1) it depends of your goal. usually I do not wait or even think about such small values (2) may be a hour, may be a day, may be a year (3) there is no consensus value for "dust". (4) up to you  
> **username_0**: Checking the below link it indicates that I should be paying 50-80 Satoshi per byte to get "Block 1". 1) What is "Block 1", "Block 2" etc  2) How fast could I expect block 1 to confirm?  3) 250 byte transaction x 80 Satoshi is 20,000 Satoshi and today that 0.11 USD is that right? http://p2sh.info/dashboard/db/fee-estimation  
> **username_2**: 80 satoshi per byte is too big for testing. 10 satoshi per byte or even 5 satoshi per byte is quite enough nowadays  

---

