Litecore-lib函数签名交易无法正常工作

时间:2019-12-03 18:27:48

标签: blockchain bitcoin litecoin

我正在尝试使用litecore-lib软件包在litecoin testnet上创建事务。 我附上代码片段。 我打印每一行以分析事务的构建方式。 调用“ sign”方法时无变化。

async.map

然后在下面附加输出。请在签名前后比较tx字符串:它们是相同的!

const litecore = require('litecore-lib');

var wif = 'cRkP6k8dDab1PDg2SvS8mbKMSxCSJfDFg6hibkKGmrfaU4xaCi9R';
var privateKey = new litecore.PrivateKey(wif, 'testnet');
var address = privateKey.toAddress('testnet');

console.log("Private key:", privateKey.toString());
console.log("WIF Private key:", privateKey.toWIF());
console.log("Address: ", address.toString()); //mmQQ2Mz1UGWtos6fGmM6sTg69itJmvxW9h



var utxo = {
  "txId" : "d095e2e921ac6f0ed5f7f886529c14d662b82feb35e1afa0051a8328855ecdf8",
  "outputIndex" : 0,
  "address" : address.toString(),
  "script" : "76a91447862fe165e6121af80d5dde1ecb478ed170565b88ac",
  "satoshis" : 100000,
  "network":'testnet'
};

var transaction = new litecore.Transaction()
console.log("\nTx Created:");
console.log(transaction.toString());

console.log("\nAdd input:");
transaction = transaction.from(utxo)
console.log(transaction.toString());

console.log("\nAdd output:");
transaction = transaction.to('mi1gqn4z9r1sm4XDjrTS8hegEaAMxYGWkW', 98000)
console.log(transaction.toString());

console.log("\nChange:");
transaction = transaction.change(address.toString())
console.log(transaction.toString());

console.log("\nFee:");
transaction = transaction.fee(1100)
console.log(transaction.toString());

console.log("Is fully signed:", transaction.isFullySigned());

console.log("\nSign:");
transaction = transaction.sign(privateKey)
console.log(transaction.toString());

console.log("Is fully signed:", transaction.isFullySigned());

1 个答案:

答案 0 :(得分:1)

确保为utxo设置了正确的脚本。

input_val = [1713,202323]

   TeamAbb    P1       P2      P3      P4      P5
7     ATL8  1713    202323  203459  1627761 1628981