Skip to content

Commit

Permalink
Merge pull request #2110 from gomezdn/fix/improve-error-message-when-…
Browse files Browse the repository at this point in the history
…signing-tx-with-no-outputs

fix: added error with clear message when signing a tx without outputs
  • Loading branch information
junderw authored Jun 15, 2024
2 parents d54a0d0 + 4802803 commit c6105c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ class Transaction {
hashSequences = bcrypto.sha256(bufferWriter.end());
}
if (!(isNone || isSingle)) {
if (!this.outs.length)
throw new Error('Add outputs to the transaction before signing.');
const txOutsSize = this.outs
.map(output => 8 + varSliceSize(output.script))
.reduce((a, b) => a + b);
Expand Down
2 changes: 2 additions & 0 deletions ts_src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ export class Transaction {
}

if (!(isNone || isSingle)) {
if (!this.outs.length)
throw new Error('Add outputs to the transaction before signing.');
const txOutsSize = this.outs
.map(output => 8 + varSliceSize(output.script))
.reduce((a, b) => a + b);
Expand Down

0 comments on commit c6105c4

Please sign in to comment.