Add stricter Signer interface check

This commit is contained in:
junderw 2019-06-13 13:32:21 +09:00
parent 969b3a5e18
commit 053d282e9d
No known key found for this signature in database
GPG key ID: B256185D3A971908
5 changed files with 19 additions and 2 deletions
ts_src

View file

@ -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;