Issue with Creating Dogecoin Transaction Using Multiple Inputs and Private Keys

40 Views Asked by At

I'm encountering an issue while trying to create a Dogecoin transaction using multiple inputs, each with their own private keys. Below is the code snippet I'm using:

const lockScript = BitcoinScript.lockScriptForAddress(trx.sender_address, CoinType.dogecoin);

const utxo_ = [];
trx.utxo.forEach(element => {
  utxo_.push(
    TW.Bitcoin.Proto.UnspentTransaction.create({
      outPoint: TW.Bitcoin.Proto.OutPoint.create({
        hash: HexCoding.decode(element.hash).reverse(),
        index: element.index,
        sequence: element.sequence 
      }),
      script: lockScript.data(),
      amount: element.amount,
    })
  );
});
const input = TW.Bitcoin.Proto.SigningInput.create({
  hashType: BitcoinSigHashType.all.value,
  amount: trx.amount,
  toAddress: trx.receiver_address,
  changeAddress: trx.sender_address,
  byteFee: trx.byte_fee,
  utxo: utxo_,
  privateKey: [
    HexCoding.decode("private_key1"),
    HexCoding.decode("private_key2"),
  ],
  coinType: CoinType.dogecoin.value,
});
const encoded = TW.Bitcoin.Proto.SigningInput.encode(input).finish();
const outputData = AnySigner.sign(encoded, CoinType.dogecoin);
const output = TW.Bitcoin.Proto.SigningOutput.decode(outputData);

When executing this code, I'm unable to successfully create a transaction. The output.error returns an error number 5, indicating a missing private key. However, as shown in the code, I've provided two private keys corresponding to the two inputs.

Could you please help me understand what might be causing this issue, and how it can be resolved? Is there a specific format or process I should follow when including multiple private keys for different UTXO inputs in Dogecoin transactions?

Any guidance or suggestions you can provide would be greatly appreciated.

When executing this code, I'm unable to successfully create a transaction. The output.error returns an error number 5, indicating a missing private key. However, as shown in the code, I've provided two private keys corresponding to the two inputs.

0

There are 0 best solutions below