bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

[HELP] I made a transaction on a testnet and there is no error. But it's not there :) #152

Closed AlexanderKozhevin closed 6 years ago

AlexanderKozhevin commented 6 years ago

I made a simple transaction on a testnet with the following code. After running it I'm getting transaction id and no errors. But I can't see that's it's done in blockchain explorer.

var bitcore = require('bitcore');
var privateKey = new bitcore.PrivateKey('2c73f72719480ed0d3f7e4cbe7991821adede4894d0e57062edf68c492328efc');
var utxo = {
  "txId" : "92d7c36eb253df95c40b8c919236f22547a41f730ca33e2681dbeb47335844d1",
  "outputIndex" : 0,
  "address" : "mwW6ADctZ7jpdgmtkYLdRxZHQE5NRPzkir",
  "script" : "76a914af5829703cd2f0677017bb3e2235f767ec57748488ac",
  "satoshis" : 130000000
};

var transaction = new bitcore.Transaction()
  .from(utxo)
  .to('mmPepE3AR7DE6YGQfksGrGDj6rQhkAqF9L', 15000)
  .sign(privateKey);
console.log(transaction)

I'm getting:

<Transaction: 0100000001d144583347ebdb81263ea30c731fa44725f23692918c0bc495df53b26ec3d7920000000000ffffffff01983a0000000000001976a914406f4066bb99985efe9d36b0ac7c4c96c799104888ac00000000>
manuel-di-iorio commented 6 years ago

You just offline signed the transaction. Now, you have to actually broadcast it to the testnet network. To do that, you could use https://testnet.blockexplorer.com/tx/send or with your own relay server, e.g. made with https://github.com/bitpay/insight

Use https://blockchain.info/it/decode-tx to decode and debug your raw transaction (works both for livenet and testnet) before to definitely send your transaction