diff --git a/src/transaction.ts b/src/transaction.ts index 858a67f..e9cc54a 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -518,7 +518,10 @@ export class Transaction { ): psbt.TransactionOutput { let { amount, script } = o; if (amount === undefined) amount = cur?.amount; - if (typeof amount !== 'bigint') throw new Error('amount must be bigint sats'); + if (typeof amount !== 'bigint') + throw new Error( + `Wrong amount type, should be of type bigint in sats, but got ${amount} of type ${typeof amount}` + ); if (typeof script === 'string') script = hex.decode(script); if (script === undefined) script = cur?.script; let res: psbt.PSBTKeyMapKeys = { ...cur, ...o, amount, script }; diff --git a/src/utxo.ts b/src/utxo.ts index f976bd4..5df85d4 100644 --- a/src/utxo.ts +++ b/src/utxo.ts @@ -284,7 +284,12 @@ function getScript(o: Output, opts: TxOpts = {}, network = NETWORK) { script = OutScript.encode(Address(network).decode(o.address)); } if (!script) throw new Error('Estimator: wrong output script'); - if (typeof o.amount !== 'bigint') throw new Error(`Estimator: wrong output amount=${o.amount}`); + if (typeof o.amount !== 'bigint') + throw new Error( + `Estimator: wrong output amount=${ + o.amount + }, should be of type bigint but got ${typeof o.amount}.` + ); if (script && !opts.allowUnknownOutputs && OutScript.decode(script).type === 'unknown') { throw new Error( 'Estimator: unknown output script type, there is a chance that input is unspendable. Pass allowUnknownOutputs=true, if you sure' @@ -333,9 +338,18 @@ export class _Estimator { private opts: EstimatorOpts ) { if (typeof opts.feePerByte !== 'bigint') - throw new Error(`Estimator: wrong feePerByte=${opts.feePerByte}`); + throw new Error( + `Estimator: wrong feePerByte=${ + opts.feePerByte + }, should be of type bigint but got ${typeof opts.feePerByte}.` + ); if (opts.dust) { - if (typeof opts.dust !== 'bigint') throw new Error(`Estimator: wrong dust=${opts.dust}`); + if (typeof opts.dust !== 'bigint') + throw new Error( + `Estimator: wrong dust=${ + opts.dust + }, should be of type bigint but got ${typeof opts.dust}.` + ); this.dust = opts.dust; } if (opts.requiredInputs !== undefined && !Array.isArray(opts.requiredInputs))