Browse Source
Add stricter Signer interface check
psbt-tx-getters
junderw
6 years ago
No known key found for this signature in database
GPG Key ID: B256185D3A971908
5 changed files with
19 additions and
2 deletions
-
src/transaction_builder.js
-
src/types.js
-
ts_src/transaction_builder.ts
-
ts_src/types.ts
-
types/types.d.ts
|
|
@ -166,7 +166,7 @@ class TransactionBuilder { |
|
|
|
`Unknown prevOutScriptType "${signParams.prevOutScriptType}"`, |
|
|
|
); |
|
|
|
} |
|
|
|
typeforce(typeforce.tuple(typeforce.Number, typeforce.Object), [ |
|
|
|
typeforce(typeforce.tuple(typeforce.Number, types.Signer), [ |
|
|
|
signParams.vin, |
|
|
|
signParams.keyPair, |
|
|
|
]); |
|
|
|
|
|
@ -13,6 +13,14 @@ exports.BIP32Path = BIP32Path; |
|
|
|
BIP32Path.toJSON = () => { |
|
|
|
return 'BIP32 derivation path'; |
|
|
|
}; |
|
|
|
function Signer(obj) { |
|
|
|
return ( |
|
|
|
(typeforce.Buffer(obj.publicKey) || |
|
|
|
typeof obj.getPublicKey === 'function') && |
|
|
|
typeof obj.sign === 'function' |
|
|
|
); |
|
|
|
} |
|
|
|
exports.Signer = Signer; |
|
|
|
const SATOSHI_MAX = 21 * 1e14; |
|
|
|
function Satoshi(value) { |
|
|
|
return typeforce.UInt53(value) && value <= SATOSHI_MAX; |
|
|
|
|
|
@ -256,7 +256,7 @@ export class TransactionBuilder { |
|
|
|
`Unknown prevOutScriptType "${signParams.prevOutScriptType}"`, |
|
|
|
); |
|
|
|
} |
|
|
|
typeforce(typeforce.tuple(typeforce.Number, typeforce.Object), [ |
|
|
|
typeforce(typeforce.tuple(typeforce.Number, types.Signer), [ |
|
|
|
signParams.vin, |
|
|
|
signParams.keyPair, |
|
|
|
]); |
|
|
|
|
|
@ -12,6 +12,14 @@ BIP32Path.toJSON = (): string => { |
|
|
|
return 'BIP32 derivation path'; |
|
|
|
}; |
|
|
|
|
|
|
|
export function Signer(obj: any): boolean { |
|
|
|
return ( |
|
|
|
(typeforce.Buffer(obj.publicKey) || |
|
|
|
typeof obj.getPublicKey === 'function') && |
|
|
|
typeof obj.sign === 'function' |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const SATOSHI_MAX: number = 21 * 1e14; |
|
|
|
export function Satoshi(value: number): boolean { |
|
|
|
return typeforce.UInt53(value) && value <= SATOSHI_MAX; |
|
|
|
|
|
@ -3,6 +3,7 @@ export declare function BIP32Path(value: string): boolean; |
|
|
|
export declare namespace BIP32Path { |
|
|
|
var toJSON: () => string; |
|
|
|
} |
|
|
|
export declare function Signer(obj: any): boolean; |
|
|
|
export declare function Satoshi(value: number): boolean; |
|
|
|
export declare const ECPoint: any; |
|
|
|
export declare const Network: any; |
|
|
|