junderw
6 years ago
No known key found for this signature in database
GPG Key ID: B256185D3A971908
3 changed files with
26 additions and
2 deletions
-
src/psbt.js
-
ts_src/psbt.ts
-
types/psbt.d.ts
|
|
@ -14,9 +14,9 @@ class Psbt extends bip174_1.Psbt { |
|
|
|
constructor(opts = {}) { |
|
|
|
super(); |
|
|
|
// set defaults
|
|
|
|
this.setVersion(2); |
|
|
|
this.opts = Object.assign({}, DEFAULT_OPTS, opts); |
|
|
|
this.__TX = transaction_1.Transaction.fromBuffer(this.globalMap.unsignedTx); |
|
|
|
this.setVersion(2); |
|
|
|
// set cache
|
|
|
|
const self = this; |
|
|
|
delete this.globalMap.unsignedTx; |
|
|
@ -44,6 +44,16 @@ class Psbt extends bip174_1.Psbt { |
|
|
|
dpew(this, '__TX_BUF_CACHE', false, true); |
|
|
|
dpew(this, 'opts', false, true); |
|
|
|
} |
|
|
|
setVersion(version) { |
|
|
|
this.__TX.version = version; |
|
|
|
this.__TX_BUF_CACHE = undefined; |
|
|
|
return this; |
|
|
|
} |
|
|
|
setLocktime(locktime) { |
|
|
|
this.__TX.locktime = locktime; |
|
|
|
this.__TX_BUF_CACHE = undefined; |
|
|
|
return this; |
|
|
|
} |
|
|
|
addInput(inputData) { |
|
|
|
const self = this; |
|
|
|
const inputAdder = (_inputData, txBuf) => { |
|
|
|
|
|
@ -23,9 +23,9 @@ export class Psbt extends PsbtBase { |
|
|
|
constructor(opts: PsbtOptsOptional = {}) { |
|
|
|
super(); |
|
|
|
// set defaults
|
|
|
|
this.setVersion(2); |
|
|
|
this.opts = Object.assign({}, DEFAULT_OPTS, opts); |
|
|
|
this.__TX = Transaction.fromBuffer(this.globalMap.unsignedTx!); |
|
|
|
this.setVersion(2); |
|
|
|
|
|
|
|
// set cache
|
|
|
|
const self = this; |
|
|
@ -61,6 +61,18 @@ export class Psbt extends PsbtBase { |
|
|
|
dpew(this, 'opts', false, true); |
|
|
|
} |
|
|
|
|
|
|
|
setVersion(version: number): this { |
|
|
|
this.__TX.version = version; |
|
|
|
this.__TX_BUF_CACHE = undefined; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
setLocktime(locktime: number): this { |
|
|
|
this.__TX.locktime = locktime; |
|
|
|
this.__TX_BUF_CACHE = undefined; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
addInput(inputData: TransactionInput): this { |
|
|
|
const self = this; |
|
|
|
const inputAdder = ( |
|
|
|
|
|
@ -8,6 +8,8 @@ export declare class Psbt extends PsbtBase { |
|
|
|
private __TX_BUF_CACHE?; |
|
|
|
private opts; |
|
|
|
constructor(opts?: PsbtOptsOptional); |
|
|
|
setVersion(version: number): this; |
|
|
|
setLocktime(locktime: number): this; |
|
|
|
addInput(inputData: TransactionInput): this; |
|
|
|
addOutput(outputData: TransactionOutput): this; |
|
|
|
extractTransaction(): Transaction; |
|
|
|