Class: BeaconUtils ​
Defined in: packages/method/src/core/beacon/utils.ts:40
Static class of utility functions for the Beacon Service BeaconUtils
Constructors ​
Constructor ​
new BeaconUtils():
BeaconUtils
Returns ​
BeaconUtils
Methods ​
generateBeacon() ​
staticgenerateBeacon(params):BeaconService
Defined in: packages/method/src/core/beacon/utils.ts:215
Generate a single beacon service.
Parameters ​
params ​
Required parameters for generating a single Beacon Service.
identifier ​
string
The identifier for the beacon service.
network ​
Network
The name of the Bitcoin network to use.
publicKey ​
Byte array representation of a public key used to generate a new btcr2 key-id-type.
type ​
string
The type of beacon service to create.
Returns ​
A BeaconService object.
Throws ​
if the bitcoin address is invalid.
generateBeaconAddresses() ​
staticgenerateBeaconAddresses(params):string[][]
Defined in: packages/method/src/core/beacon/utils.ts:97
Generate all 3 Beacon Service Endpoints for a given public key.
Parameters ​
params ​
Required parameters for generating Beacon Services.
identifier ​
string
network ​
Network
Bitcoin network interface from bitcoinlib-js.
publicKey ​
Public key bytes used to generate the beacon object serviceEndpoint.
Returns ​
string[][]
2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
Throws ​
if the bitcoin address is invalid.
generateBeaconService() ​
staticgenerateBeaconService(params):BeaconService
Defined in: packages/method/src/core/beacon/utils.ts:130
Generate a set of Beacon Services for a given public key.
Parameters ​
params ​
Required parameters for generating Beacon Services.
addressType ​
"p2pkh" | "p2wpkh" | "p2tr"
The type of address to create (p2pkh, p2wpkh, p2tr).
id ​
string
network ​
Network
Bitcoin network interface from bitcoinlib-js.
publicKey ​
Public key bytes used to generate the beacon object serviceEndpoint.
type ​
string
Returns ​
A BeaconService object.
Throws ​
if the bitcoin address is invalid.
generateBeaconServiceCustom() ​
staticgenerateBeaconServiceCustom(params):BeaconService
Defined in: packages/method/src/core/beacon/utils.ts:154
Generate a custom Beacon Service.
Parameters ​
params ​
Required parameters for generating Beacon Services.
addressType ​
"p2pkh" | "p2wpkh" | "p2tr"
id ​
string
network ​
Network
publicKey ​
type ​
string
Returns ​
generateBeaconServices() ​
staticgenerateBeaconServices(params):BeaconService[]
Defined in: packages/method/src/core/beacon/utils.ts:185
Generate beacon services.
Parameters ​
params ​
Required parameters for generating Beacon Services.
identifier ​
string
network ​
Network
The name of the Bitcoin network to use.
publicKey ​
Byte array representation of a public key used to generate a new btcr2 key-id-type.
type ​
string
Returns ​
Array of DidService objects.
getBeaconServiceAddressMap() ​
staticgetBeaconServiceAddressMap(beacons):Map<string,BeaconServiceAddress>
Defined in: packages/method/src/core/beacon/utils.ts:263
Create a map of address => beaconService with address field.
Parameters ​
beacons ​
The list of beacon services.
Returns ​
Map<string, BeaconServiceAddress>
A map of address => beaconService.
getBeaconServiceIds() ​
staticgetBeaconServiceIds(didDocument):string[]
Defined in: packages/method/src/core/beacon/utils.ts:273
Get the beacon service ids from a list of beacon services.
Parameters ​
didDocument ​
The DID Document to extract the services from.
Returns ​
string[]
An array of beacon service ids.
getBeaconServices() ​
staticgetBeaconServices(didDocument):BeaconService[]
Defined in: packages/method/src/core/beacon/utils.ts:82
Extracts the services from a given DID Document
Parameters ​
didDocument ​
The DID Document to extract the services from
Returns ​
An array of DidService objects
Throws ​
if the didDocument is not provided
isBeaconService() ​
staticisBeaconService(obj):boolean
Defined in: packages/method/src/core/beacon/utils.ts:59
Validates that the given object is a Beacon Service
Parameters ​
obj ​
any
The object to validate
Returns ​
boolean
A boolean indicating whether the object is a Beacon Service
manufactureBeacon() ​
staticmanufactureBeacon(params):BeaconService
Defined in: packages/method/src/core/beacon/utils.ts:245
Manufacture a pre-filled Beacon using the BeaconFactory.
Parameters ​
params ​
Required parameters for generating a single Beacon Service.
Returns ​
One BeaconService object.
parseBitcoinAddress() ​
staticparseBitcoinAddress(uri):string
Defined in: packages/method/src/core/beacon/utils.ts:47
Converts a BIP21 Bitcoin URI to a Bitcoin address
Parameters ​
uri ​
string
The BIP21 Bitcoin URI to convert
Returns ​
string
The Bitcoin address extracted from the URI
Throws ​
if the URI is not a valid Bitcoin URI
toBeaconServiceAddress() ​
statictoBeaconServiceAddress(beacons):BeaconServiceAddress[]
Defined in: packages/method/src/core/beacon/utils.ts:254
Convert beacon service endpoints from BIP-21 URIs to addresses.
Parameters ​
beacons ​
The list of beacon services.
Returns ​
An array of beacon services with address: bitcoinAddress.