Skip to main content

TestWallet

scrypt-ts / TestWallet

Class: TestWallet

An implemention of a simple wallet which should just be used in dev/test environments. It can hold multiple private keys and have a feature of cachable in-memory utxo management.

Reminder: DO NOT USE IT IN PRODUCTION ENV.

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new TestWallet(privateKey, provider?)

Parameters

NameType
privateKeyPrivateKey | PrivateKey[]
provider?Provider

Overrides

Signer.constructor

Defined in

dist/bsv/wallets/test-wallet.d.ts:15

Properties

_checkAddressOption

Private _checkAddressOption: any

Defined in

dist/bsv/wallets/test-wallet.d.ts:36


_getAddressesIn

Private _getAddressesIn: any

Defined in

dist/bsv/wallets/test-wallet.d.ts:35


_getPrivateKeys

Private _getPrivateKeys: any

Defined in

dist/bsv/wallets/test-wallet.d.ts:38


_isSigner

Readonly _isSigner: boolean

Inherited from

Signer._isSigner

Defined in

dist/bsv/abstract-signer.d.ts:57


_privateKeys

Private Readonly _privateKeys: any

Defined in

dist/bsv/wallets/test-wallet.d.ts:12


_utxoManagers

Private _utxoManagers: any

Defined in

dist/bsv/wallets/test-wallet.d.ts:13


provider

Optional provider: Provider

Inherited from

Signer.provider

Defined in

dist/bsv/abstract-signer.d.ts:56


splitFeeTx

Private splitFeeTx: any

Defined in

dist/bsv/wallets/test-wallet.d.ts:14

Accessors

_defaultPrivateKey

Private get _defaultPrivateKey(): any

Returns

any

Defined in

dist/bsv/wallets/test-wallet.d.ts:37


addresses

get addresses(): string[]

Returns

string[]

Defined in

dist/bsv/wallets/test-wallet.d.ts:23


connectedProvider

get connectedProvider(): Provider

Get the connected provider.

Throws

if no provider is connected to this.

Returns

Provider

the connected provider.

Inherited from

Signer.connectedProvider

Defined in

dist/bsv/abstract-signer.d.ts:133


network

get network(): Network

Returns

Network

Defined in

dist/bsv/wallets/test-wallet.d.ts:22

Methods

addPrivateKey

addPrivateKey(privateKey): TestWallet

Parameters

NameType
privateKeyPrivateKey | PrivateKey[]

Returns

TestWallet

Defined in

dist/bsv/wallets/test-wallet.d.ts:24


checkPrivateKeys

checkPrivateKeys(): Network

Returns

Network

Defined in

dist/bsv/wallets/test-wallet.d.ts:25


connect

connect(provider?): Promise<TestWallet>

Connect a provider to this. If a new provider is specified when connecting, a connection will be established for the new provider and then switched to the new provider. If no new provider is specified, a connection is established for signer's built-in provider. If neither exists, an exception is thrown.

Parameters

NameTypeDescription
provider?ProviderThe target provider.

Returns

Promise<TestWallet>

Overrides

Signer.connect

Defined in

dist/bsv/wallets/test-wallet.d.ts:33


enableSplitFeeTx

enableSplitFeeTx(on): void

Parameters

NameType
onboolean

Returns

void

Defined in

dist/bsv/wallets/test-wallet.d.ts:16


getBalance

getBalance(address?): Promise<{ confirmed: number ; unconfirmed: number }>

Get the balance of BSVs in satoshis for an address.

Parameters

NameTypeDescription
address?AddressThe query address.

Returns

Promise<{ confirmed: number ; unconfirmed: number }>

A promise which resolves to the address balance status.

Inherited from

Signer.getBalance

Defined in

dist/bsv/abstract-signer.d.ts:153


getDefaultAddress

getDefaultAddress(): Promise<Address>

Returns

Promise<Address>

A promise which resolves to the address to the default private key of the signer.

Overrides

Signer.getDefaultAddress

Defined in

dist/bsv/wallets/test-wallet.d.ts:26


getDefaultPubKey

getDefaultPubKey(): Promise<PublicKey>

Returns

Promise<PublicKey>

A promise which resolves to the public key of the default private key of the signer.

Overrides

Signer.getDefaultPubKey

Defined in

dist/bsv/wallets/test-wallet.d.ts:27


getPubKey

getPubKey(address): Promise<PublicKey>

Throws

If the private key for the address does not belong this signer.

Parameters

NameTypeDescription
addressAddressThe request address, using the default address if omitted.

Returns

Promise<PublicKey>

The public key result.

Overrides

Signer.getPubKey

Defined in

dist/bsv/wallets/test-wallet.d.ts:28


getSignatures

getSignatures(rawTxHex, sigRequests): Promise<SignatureResponse[]>

Get the requested transaction signatures for the raw transaction.

Parameters

NameTypeDescription
rawTxHexstringThe raw transaction hex to get signatures from.
sigRequestsSignatureRequest[]The signature requst informations, see details in SignatureRequest.

Returns

Promise<SignatureResponse[]>

A promise which resolves to a list of SignatureReponse corresponding to sigRequests.

Overrides

Signer.getSignatures

Defined in

dist/bsv/wallets/test-wallet.d.ts:32


isAuthenticated

isAuthenticated(): Promise<boolean>

Check if the wallet has been authenticated

Returns

Promise<boolean>

true | false

Overrides

Signer.isAuthenticated

Defined in

dist/bsv/wallets/test-wallet.d.ts:17


listUnspent

listUnspent(address, options?): Promise<IUnspentOutput[]>

Get a list of the P2PKH UTXOs.

Parameters

NameTypeDescription
addressAddressThe address of the returned UTXOs belongs to.
options?UtxoQueryOptionsThe optional query conditions, see details in UtxoQueryOptions.

Returns

Promise<IUnspentOutput[]>

A promise which resolves to a list of UTXO for the query options.

Overrides

Signer.listUnspent

Defined in

dist/bsv/wallets/test-wallet.d.ts:34


requestAuth

requestAuth(): Promise<{ error: string ; isAuthenticated: boolean }>

Request wallet authentication

Returns

Promise<{ error: string ; isAuthenticated: boolean }>

A promise which resolves to if the wallet has been authenticated and the authenticate error message

Overrides

Signer.requestAuth

Defined in

dist/bsv/wallets/test-wallet.d.ts:18


signAndsendTransaction

signAndsendTransaction(tx, options?): Promise<TransactionResponse>

Sign transaction and broadcast it

Parameters

NameTypeDescription
txTransactionA transaction is signed and broadcast
options?SignTransactionOptionsThe options for signing, see the details of SignTransactionOptions.

Returns

Promise<TransactionResponse>

A promise which resolves to the transaction id.

Overrides

Signer.signAndsendTransaction

Defined in

dist/bsv/wallets/test-wallet.d.ts:39


signMessage

signMessage(message, address?): Promise<string>

Sign a message string.

Parameters

NameTypeDescription
messagestringThe message to be signed.
address?AddressThe optional address whose private key will be used to sign message, using the default private key if omitted.

Returns

Promise<string>

A promise which resolves to the signautre of the message.

Overrides

Signer.signMessage

Defined in

dist/bsv/wallets/test-wallet.d.ts:31


signRawTransaction

signRawTransaction(rawTxHex, options): Promise<string>

Sign a raw transaction hex string.

Throws

If any input of the transaction can not be signed properly.

Parameters

NameTypeDescription
rawTxHexstringThe raw transaction hex to sign.
optionsSignTransactionOptionsThe options for signing, see the details of SignTransactionOptions.

Returns

Promise<string>

A promise which resolves to the signed transaction hex string.

Overrides

Signer.signRawTransaction

Defined in

dist/bsv/wallets/test-wallet.d.ts:29


signTransaction

signTransaction(tx, options?): Promise<Transaction>

Sign a transaction object.

Parameters

NameTypeDescription
txTransactionThe transaction object to sign.
options?SignTransactionOptionsThe options for signing, see the details of SignTransactionOptions.

Returns

Promise<Transaction>

A promise which resolves to the signed transaction object.

Overrides

Signer.signTransaction

Defined in

dist/bsv/wallets/test-wallet.d.ts:30


isSigner

Static isSigner(value): value is Signer

Check if an object is a Signer

Parameters

NameTypeDescription
valueanyThe target object

Returns

value is Signer

Returns true if and only if object is a Provider.

Inherited from

Signer.isSigner

Defined in

dist/bsv/abstract-signer.d.ts:162