@secux/app-btc
Version:
SecuX Hardware Wallet BTC API
112 lines (108 loc) • 3.34 kB
TypeScript
/*!
Copyright 2022 SecuX Technology Inc
Copyright Chen Wei-En
Copyright Wu Tsung-Yu
Licensed under the Apache License, Version 2.0 (the License);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an AS IS BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/// <reference types="node" />
/// <reference types="node" />
import { CoinType, ScriptType } from './interface';
import { bs58Check } from "@secux/utility/lib/bs58";
export { PaymentBTC, CoinType, Hash160 };
export declare const logger: any;
declare class PaymentBTC {
protected static bs58check: bs58Check;
protected static CoinSupported(coin: CoinType): void;
/**
* Pay to Public Key Hash for BTC compatible coin
* @param {CoinType} coin
* @param {Buffer} opt [publickey | hashed publickey]
* @returns
*/
static p2pkh(coin: CoinType, opt: {
publickey?: Buffer;
hash?: Buffer;
}): {
address: string;
scriptPublickey: Buffer;
};
/**
* Pay to Script Hash for BTC compatible coin
* @param {CoinType} coin
* @param {Buffer} opt [redeemScript | hashed redeem]
* @returns
*/
static p2sh(coin: CoinType, opt: {
redeemScript?: Buffer;
hash?: Buffer;
}): {
address: string;
scriptPublickey: Buffer;
};
/**
* Pay to Witness Public Key Hash
* @param {CoinType} coin
* @param {Buffer} opt [publickey | hashed publickey]
* @returns
*/
static p2wpkh(coin: CoinType, opt: {
publickey?: Buffer;
hash?: Buffer;
}): {
address: string;
scriptPublickey: Buffer;
};
/**
* Pay to Witness Script Hash
* @param {CoinType} coin
* @param {Buffer} opt [redeemScript | hashed redeem]
* @returns
*/
static p2wsh(coin: CoinType, opt: {
redeemScript?: Buffer;
hash?: Buffer;
}): {
address: string;
scriptPublickey: Buffer;
};
/**
* Pay to MultiSig
* @param {number} m
* @param {Array<Buffer>} publickeys
* @returns
*/
static p2ms(m: number, publickeys: Array<Buffer>): {
scriptPubicKey: Buffer;
};
static p2tr(coin: CoinType, opt: {
publickey?: Buffer;
hash?: Buffer;
}): {
address: string;
scriptPublickey: Buffer;
};
/**
* decode address to script
* @param {CoinType} coin
* @param {string} address
*/
static decode(coin: CoinType, address: string): Buffer;
static encode(coin: CoinType, script: Buffer): string;
static classify(script: Buffer): ScriptType;
static isP2PKH(script: Buffer): boolean;
static isP2SH(script: Buffer): boolean;
static isP2WPKH(script: Buffer): boolean;
static isP2WSH(script: Buffer): boolean;
static isP2TR(script: Buffer): boolean;
static isP2MS(script: Buffer): boolean;
static isArbitraryData(script: Buffer): boolean;
}
declare function Hash160(publickey: Buffer): Buffer;