import { BaseMultisigData , createUnitConverters , MultisigData , NetworkType } from '@bitaccess/coinlib-common' ; import * as bitcoin from 'bitcoinjs-lib' ; import { DECIMAL_PLACES , NETWORKS } from './constants' ; import * as bitcoinish from './bitcoinish' ; import { BitcoinjsNetwork } from './types' ; export { getMultisigPaymentScript , getSinglesigPaymentScript , publicKeyToAddress , publicKeyToKeyPair , publicKeyToString , publicKeyToBuffer , privateKeyToKeyPair , privateKeyToAddress , } from './bitcoinish' ; const { toMainDenominationBigNumber , toMainDenominationString , toMainDenominationNumber , toBaseDenominationBigNumber , toBaseDenominationString , toBaseDenominationNumber , } = createUnitConverters ( DECIMAL_PLACES ) ; export { toMainDenominationBigNumber , toMainDenominationString , toMainDenominationNumber , toBaseDenominationBigNumber , toBaseDenominationString , toBaseDenominationNumber , } ; export function isValidAddress ( address , networkType ) { return bitcoinish . isValidAddress ( address , NETWORKS [ networkType ] ) ; } export function standardizeAddress ( address , networkType ) { return bitcoinish . standardizeAddress ( address , NETWORKS [ networkType ] ) ; } export function isValidPublicKey ( publicKey , networkType ) { return bitcoinish . isValidPublicKey ( publicKey , NETWORKS [ networkType ] ) ; } export function isValidExtraId ( extraId ) { return bitcoinish . isValidExtraId ( extraId ) ; } export function isValidPrivateKey ( privateKey , networkType ) { return bitcoinish . isValidPrivateKey ( privateKey , NETWORKS [ networkType ] ) ; } export function estimateBitcoinTxSize ( inputCounts , outputCounts , networkType ) { return bitcoinish . estimateTxSize ( inputCounts , outputCounts , ( address ) => bitcoin . address . toOutputScript ( address , NETWORKS [ networkType ] ) ) ; } export function isMultisigFullySigned ( multisigData ) { if ( BaseMultisigData . is ( multisigData ) ) { return multisigData . signedAccountIds . length >= multisigData . m ; } return Object . values ( multisigData ) . every ( isMultisigFullySigned ) ; }