Skip to content

Commit 4802803

Browse files
gomezdnjunderw
authored andcommitted
fix: added error with clear message when signing a tx without outputs
1 parent d54a0d0 commit 4802803

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/transaction.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ class Transaction {
318318
hashSequences = bcrypto.sha256(bufferWriter.end());
319319
}
320320
if (!(isNone || isSingle)) {
321+
if (!this.outs.length)
322+
throw new Error('Add outputs to the transaction before signing.');
321323
const txOutsSize = this.outs
322324
.map(output => 8 + varSliceSize(output.script))
323325
.reduce((a, b) => a + b);

ts_src/transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ export class Transaction {
414414
}
415415

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

0 commit comments

Comments
 (0)