Skip to main content

Signer

scrypt-ts / Signer

Class: Signer

A Signer is a class which in some way directly or indirectly has access to a private key, which can sign messages and transactions to authorize the network to perform operations.

Hierarchy​

Table of contents​

Constructors​

Properties​

Accessors​

Methods​

Constructors​

constructor​

• new Signer(provider?)

Parameters​

NameType
provider?Provider

Defined in​

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

Properties​

_isSigner​

• Readonly _isSigner: boolean

Defined in​

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


provider​

• Optional provider: Provider

Defined in​

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

Accessors​

connectedProvider​

• get connectedProvider(): Provider

Get the connected provider.

Throws

if no provider is connected to this.

Returns​

Provider

the connected provider.

Defined in​

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

Methods​

connect​

▸ Abstract connect(newProvider?): Promise<Signer>

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
newProvider?ProviderThe target provider.

Returns​

Promise<Signer>

Defined in​

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


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.

Defined in​

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


getDefaultAddress​

▸ Abstract getDefaultAddress(): Promise<Address>

Returns​

Promise<Address>

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

Defined in​

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


getDefaultPubKey​

▸ Abstract getDefaultPubKey(): Promise<PublicKey>

Returns​

Promise<PublicKey>

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

Defined in​

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


getPubKey​

▸ Abstract getPubKey(address?): Promise<PublicKey>

Throws

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

Parameters​

NameTypeDescription
address?AddressThe request address, using the default address if omitted.

Returns​

Promise<PublicKey>

The public key result.

Defined in​

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


getSignatures​

▸ Abstract 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.

Defined in​

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


isAuthenticated​

▸ Abstract isAuthenticated(): Promise<boolean>

Check if the wallet has been authenticated

Returns​

Promise<boolean>

true | false

Defined in​

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


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.

Defined in​

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


requestAuth​

▸ Abstract 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

Defined in​

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


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.

Defined in​

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


signMessage​

▸ Abstract 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.

Defined in​

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


signRawTransaction​

▸ Abstract 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.

Defined in​

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


signTransaction​

▸ Abstract 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.

Defined in​

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


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.

Defined in​

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