Bitcoin API
A set of methods for obtaining public keys, signing messages, and transactions specific to the Bitcoin network and protocols based on it (Litecoin, Dogecoin, etc.).
Networks
The list of supported networks determines the BIP32 constraints, displayed data formats, and types of supported addresses.
Network | Symbol | ID | Description |
---|---|---|---|
Bitcoin | BTC | 1 | The Bitcoin mainnet is the primary and original blockchain network of Bitcoin where all major transactions and activities take place, as opposed to test or alternative networks. |
Testnet Bitcoin | tBTC | 2 | The Bitcoin testnet is a separate blockchain network designed for testing and experimentation, allowing developers and users to trial new features or conduct experiments without using real bitcoins on the mainnet. |
Litecoin | LTC | 3 | The Litecoin mainnet refers to the primary and operational blockchain network of Litecoin, a peer-to-peer cryptocurrency. On the Litecoin mainnet, real transactions and activities occur, distinguishing it from testnets or alternative networks. |
Testnet Litecoin | tLTC | 4 | The Litecoin testnet is a distinct blockchain network specifically created for testing purposes. It enables developers and users to experiment with new features, test applications, and conduct trials without using real Litecoin on the mainnet. |
Dogecoin | DOGE | 5 | The Dogecoin mainnet refers to the primary and original blockchain network of Dogecoin. It is the decentralized ledger where actual Dogecoin transactions and activities occur. |
Bitcoin BTC
Address Type | Description | BIP32 Mainnet | BIP32 Testnet |
---|---|---|---|
P2PKH | Legacy | m/44'/0'/0' | m/44'/1'/0' |
P2WPKH | Segwit | m/84'/0'/0' | m/84'/1'/0' |
P2SH_P2WPKH | Nested Segwit | m/49'/0'/0' | m/49'/1'/0' |
P2TR | Taproot | m/86'/0'/0' | m/86'/1'/0' |
Litecoin LTC
Address Type | Description | BIP32 Mainnet | BIP32 Testnet |
---|---|---|---|
P2PKH | Legacy | m/44'/2'/0' | m/44'/1'/0' |
P2WPKH | Segwit | m/84'/2'/0' | m/84'/1'/0' |
P2SH_P2WPKH | Nested Segwit | m/49'/2'/0' | m/49'/1'/0' |
Dogecoin DOGE
Address Type | Description | BIP32 Mainnet |
---|---|---|
P2PKH | Legacy | m/44'/3'/0' |
Methods
Method | App ID | Method ID | Description |
---|---|---|---|
GET_PUBLIC_KEY | 2 | 1 | Request to obtain an HD public key via the BIP32 path |
SIGN_MESSAGE | 2 | 2 | Request to sign a message (Bitcoin Signed Messages) |
SIGN_TRANSACTION | 2 | 3 | Request to sign a transaction |
GET_PUBLIC_KEY
Returns an HD node corresponding to the specified BIP32 path.
Request
bitcoin.proto
message GetPublicKey {
uint32 network = 1;
Bip32Path path = 2;
}
- network: Network identifier, see NETWORKS
- path: BIP32 path of the key to obtain the HD node.
Response
bitcoin.proto
message GetPublicKeyResult {
uint32 depth = 1;
uint32 index = 2;
bytes publicKey = 3;
bytes chainCode = 4;
uint32 fingerprint = 5;
}
SIGN_MESSAGE
Generates a signature for the message msg using the magic hash (Bitcoin Signed Messages).
Request
bitcoin.proto
message SignMessage {
uint32 network = 1;
Bip32Path path = 2;
bytes msg = 3;
}
- network: Network identifier, see NETWORKS
- path: BIP32 path of the key for signing the message
- msg: Message to be signed.
Response
bitcoin.proto
message ECDSASignResult {
uint32 v = 1;
bytes r = 2;
bytes s = 3;
}
- v, r, s:: component of the ECDSA signature.
SIGN_TRANSACTION
Signs the inputs of a UTXO transaction in the PSBT (Partially Signed Bitcoin Transaction) format.
Request
bitcoin.proto
message SignTransaction {
uint32 network = 1;
bytes psbt = 2;
map<uint32, Bip32Path> paths = 3;
map<uint32, Bip32Path> changePaths = 4;
bool finalize = 5;
}
- network: Network identifier, see NETWORKS.
- psbt: Serialized transaction in PSBT format.
- paths: Transaction input indices and their corresponding BIP32 paths for signing.
- changePaths: Transaction output indices and their corresponding BIP32 paths, representing change addresses for accurate display of the sending amount.
- finalize: Flag indicating whether transaction finalization is required. If set to true, the result will be a fully formed transaction in blockchain format; otherwise, it will be a PSBT.
Response
bitcoin.proto
message SignTransactionResult {
bytes tx = 1;
}
- tx: PSBT or Bitcoin Transaction.