Invalid state: undefined
Error
at Error.NodeError (/Users/NAMW/node_modules/bitcore-lib/lib/errors/index.js:20:41)
at Object.module.exports.checkState (/Users/NAME/node_modules/bitcore-lib/lib/util/preconditions.js:9:13)
at Transaction.sign (/Users/SONGDAVIDZHIYU/node_modules/bitcore-lib/lib/transaction/transaction.js:1053:5)
at repl:1:4
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer. (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
Do you mean I should contain UTXO information in Transaction?
So if I write down code, how to implement?
My expectation is below.
■TO search UTXO
var UTXOS = ' ';
var address = 'SENDER ADDRESS';
var Insight = require('bitcore-explorers').Insight;
var insight = new Insight('testnet');
insight.getUnspentUtxos(address, function(err, utxos){
if (err){
// Handle errors...
} else {
UTXOS = utxos
}
【QUESTION】
I know totally how to collect UTXOS information.
But how to sign the transaction that is made by another protocol.
As I mentioned before, I want to create transaction using Counterparty protocol.
So I want to use ‘IndieSquare API’.
When I use this API to create a transaction, it returns ‘unsigned_txid’ which is hexadecimal style.
var unsigned_txid = '010000000414ae2264cdbe754b9ae4be18d84bfeb4f578af553b9b9e4f9cb2303d04ee9e45000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffffec15d27b74516fefd921cecbe043ea63124d28a3903aef8fb1682ccc926b1c62000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff9878f76e1424c1d1eeb6b15d06902dd8f0c78f9bdb61263e4ca3ae68c571a292000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acfffffffffdac7f1c83b01a8924a8965d356b804c2608bc261fc18041116ddb4a143bc499000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff0336150000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac00000000000000001e6a1c246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e92180000000000001976a91458b6e991b45487df810f4d96d5315da739637f1788ac00000000';
When I put the info into the variable, how to sign?
Just simply sign like below?
var privateKey = 'PRIVATE_KEY';
var tx = bitcore.Transaction(unsigned_txid);
tx.from = (UTXOS);
tx.sign(privateKey);