Merge pull request #1506 from longhoangwkm/fix-property-doesnt-exist-error-types
Fix error TS2339: Property valueBuffer does not exist on type OpenOutput
This commit is contained in:
commit
29e319525f
2 changed files with 10 additions and 23 deletions
|
@ -36,18 +36,13 @@ const ONE: Buffer = Buffer.from(
|
||||||
'hex',
|
'hex',
|
||||||
);
|
);
|
||||||
const VALUE_UINT64_MAX: Buffer = Buffer.from('ffffffffffffffff', 'hex');
|
const VALUE_UINT64_MAX: Buffer = Buffer.from('ffffffffffffffff', 'hex');
|
||||||
const BLANK_OUTPUT: BlankOutput = {
|
const BLANK_OUTPUT = {
|
||||||
script: EMPTY_SCRIPT,
|
script: EMPTY_SCRIPT,
|
||||||
valueBuffer: VALUE_UINT64_MAX,
|
valueBuffer: VALUE_UINT64_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
function isOutput(out: Output | BlankOutput): out is Output {
|
function isOutput(out: Output): boolean {
|
||||||
return (out as Output).value !== undefined;
|
return out.value !== undefined;
|
||||||
}
|
|
||||||
|
|
||||||
export interface BlankOutput {
|
|
||||||
script: Buffer;
|
|
||||||
valueBuffer: Buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Output {
|
export interface Output {
|
||||||
|
@ -55,8 +50,6 @@ export interface Output {
|
||||||
value: number;
|
value: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpenOutput = Output | BlankOutput;
|
|
||||||
|
|
||||||
export interface Input {
|
export interface Input {
|
||||||
hash: Buffer;
|
hash: Buffer;
|
||||||
index: number;
|
index: number;
|
||||||
|
@ -185,7 +178,7 @@ export class Transaction {
|
||||||
version: number = 1;
|
version: number = 1;
|
||||||
locktime: number = 0;
|
locktime: number = 0;
|
||||||
ins: Input[] = [];
|
ins: Input[] = [];
|
||||||
outs: OpenOutput[] = [];
|
outs: Output[] = [];
|
||||||
|
|
||||||
isCoinbase(): boolean {
|
isCoinbase(): boolean {
|
||||||
return (
|
return (
|
||||||
|
@ -275,7 +268,7 @@ export class Transaction {
|
||||||
newTx.outs = this.outs.map(txOut => {
|
newTx.outs = this.outs.map(txOut => {
|
||||||
return {
|
return {
|
||||||
script: txOut.script,
|
script: txOut.script,
|
||||||
value: (txOut as Output).value,
|
value: txOut.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -333,7 +326,7 @@ export class Transaction {
|
||||||
|
|
||||||
// "blank" outputs before
|
// "blank" outputs before
|
||||||
for (let i = 0; i < inIndex; i++) {
|
for (let i = 0; i < inIndex; i++) {
|
||||||
txTmp.outs[i] = BLANK_OUTPUT;
|
(txTmp.outs as any)[i] = BLANK_OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore sequence numbers (except at inIndex)
|
// ignore sequence numbers (except at inIndex)
|
||||||
|
@ -445,7 +438,7 @@ export class Transaction {
|
||||||
toffset = 0;
|
toffset = 0;
|
||||||
|
|
||||||
this.outs.forEach(out => {
|
this.outs.forEach(out => {
|
||||||
writeUInt64((out as Output).value);
|
writeUInt64(out.value);
|
||||||
writeVarSlice(out.script);
|
writeVarSlice(out.script);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -458,7 +451,7 @@ export class Transaction {
|
||||||
|
|
||||||
tbuffer = Buffer.allocUnsafe(8 + varSliceSize(output.script));
|
tbuffer = Buffer.allocUnsafe(8 + varSliceSize(output.script));
|
||||||
toffset = 0;
|
toffset = 0;
|
||||||
writeUInt64((output as Output).value);
|
writeUInt64(output.value);
|
||||||
writeVarSlice(output.script);
|
writeVarSlice(output.script);
|
||||||
|
|
||||||
hashOutputs = bcrypto.hash256(tbuffer);
|
hashOutputs = bcrypto.hash256(tbuffer);
|
||||||
|
@ -602,7 +595,7 @@ export class Transaction {
|
||||||
if (isOutput(txOut)) {
|
if (isOutput(txOut)) {
|
||||||
writeUInt64(txOut.value);
|
writeUInt64(txOut.value);
|
||||||
} else {
|
} else {
|
||||||
writeSlice(txOut.valueBuffer);
|
writeSlice((txOut as any).valueBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeVarSlice(txOut.script);
|
writeVarSlice(txOut.script);
|
||||||
|
|
8
types/transaction.d.ts
vendored
8
types/transaction.d.ts
vendored
|
@ -1,12 +1,7 @@
|
||||||
export interface BlankOutput {
|
|
||||||
script: Buffer;
|
|
||||||
valueBuffer: Buffer;
|
|
||||||
}
|
|
||||||
export interface Output {
|
export interface Output {
|
||||||
script: Buffer;
|
script: Buffer;
|
||||||
value: number;
|
value: number;
|
||||||
}
|
}
|
||||||
declare type OpenOutput = Output | BlankOutput;
|
|
||||||
export interface Input {
|
export interface Input {
|
||||||
hash: Buffer;
|
hash: Buffer;
|
||||||
index: number;
|
index: number;
|
||||||
|
@ -28,7 +23,7 @@ export declare class Transaction {
|
||||||
version: number;
|
version: number;
|
||||||
locktime: number;
|
locktime: number;
|
||||||
ins: Input[];
|
ins: Input[];
|
||||||
outs: OpenOutput[];
|
outs: Output[];
|
||||||
isCoinbase(): boolean;
|
isCoinbase(): boolean;
|
||||||
addInput(hash: Buffer, index: number, sequence?: number, scriptSig?: Buffer): number;
|
addInput(hash: Buffer, index: number, sequence?: number, scriptSig?: Buffer): number;
|
||||||
addOutput(scriptPubKey: Buffer, value: number): number;
|
addOutput(scriptPubKey: Buffer, value: number): number;
|
||||||
|
@ -56,4 +51,3 @@ export declare class Transaction {
|
||||||
private __byteLength;
|
private __byteLength;
|
||||||
private __toBuffer;
|
private __toBuffer;
|
||||||
}
|
}
|
||||||
export {};
|
|
||||||
|
|
Loading…
Reference in a new issue