Add version and locktime setters

This commit is contained in:
junderw 2019-07-04 13:42:34 +09:00
parent f7e726a8eb
commit 539c88596a
No known key found for this signature in database
GPG key ID: B256185D3A971908
3 changed files with 26 additions and 2 deletions
ts_src

View file

@ -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 = (