Add setters for version and locktime

This commit is contained in:
Luke Childs 2020-04-26 17:43:58 +07:00
parent c9b2964546
commit 58cdb3a362
3 changed files with 16 additions and 2 deletions

View file

@ -100,9 +100,15 @@ class Psbt {
get version() {
return this.__CACHE.__TX.version;
}
set version(version) {
this.setVersion(version);
}
get locktime() {
return this.__CACHE.__TX.locktime;
}
set locktime(locktime) {
this.setLocktime(locktime);
}
get inputs() {
return this.__CACHE.__TX.ins.map(input => ({
hash: bufferutils_1.cloneBuffer(input.hash),

View file

@ -133,10 +133,18 @@ export class Psbt {
return this.__CACHE.__TX.version;
}
set version(version: number) {
this.setVersion(version);
}
get locktime(): number {
return this.__CACHE.__TX.locktime;
}
set locktime(locktime: number) {
this.setLocktime(locktime);
}
get inputs(): Input[] {
return this.__CACHE.__TX.ins.map(input => ({
hash: cloneBuffer(input.hash),

4
types/psbt.d.ts vendored
View file

@ -44,8 +44,8 @@ export declare class Psbt {
private opts;
constructor(opts?: PsbtOptsOptional, data?: PsbtBase);
readonly inputCount: number;
readonly version: number;
readonly locktime: number;
version: number;
locktime: number;
readonly inputs: Input[];
readonly outputs: Output[];
combine(...those: Psbt[]): this;