Skip to content

Commit

Permalink
fix: added error with clear message when signing a tx without outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
gomezdn authored and junderw committed Jun 15, 2024
1 parent d54a0d0 commit 4802803
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 4802803

Please sign in to comment.