Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
318986d
feat: Cake update v1
Feb 5, 2024
9611e9d
fix: delete invalid script
Feb 8, 2024
235ec36
fix: use p2wpkh as default for validate
Feb 13, 2024
b2e9947
feat: pull in new test vectors, adjust to latest bip0352 spec
Feb 25, 2024
076c2a1
feat: move generateLabel to SP, SP type implements base address type
Feb 27, 2024
43b80bc
chore: change repo owner
Feb 27, 2024
be980da
feat: adjust tests, add receiverTweak for scanning
Feb 27, 2024
7634511
feat: change outputsToCheck
Feb 27, 2024
f45e34d
fix: refactor, test fixes
Mar 1, 2024
336694b
fix: undetected labels
Mar 5, 2024
0bacc8d
feat: improvements for readabiliy and performance
Mar 10, 2024
fb4c0a0
fix: transaction builder with non-tweak silent payment version
Mar 11, 2024
e4b354f
fix: litecoin address type regexes
Mar 19, 2024
3fd81d2
Merge remote-tracking branch 'upstream/main' into cake-update-v2
Mar 19, 2024
3ddad3d
fix: inconsistent p2tr as input silent payments
Apr 10, 2024
22b3f3d
feat: move tweak to privkeyInfo
Apr 17, 2024
2a18ab9
feat: add silent payment output builder to bitcoin transaction builder
Apr 18, 2024
539c409
fix: mixed segwit legacy
Apr 18, 2024
9967ecc
fix: mixed segwit legacy
Apr 18, 2024
01d844a
Merge pull request #1 from cake-tech/fix-mixed-case
OmarHatem28 Apr 18, 2024
b601e3f
Support MWEB addresses
hectorchu Apr 22, 2024
5d4c488
signing updates
fossephate Apr 22, 2024
1494817
Merge branch 'cake-update-v2' of https://github.com/cake-tech/bitcoin…
fossephate Apr 23, 2024
6ce628f
Stubs for MWEB
hectorchu Apr 24, 2024
5a9595f
Fix mweb scriptpubkey
hectorchu Apr 25, 2024
7752e64
Fix mweb address detection
hectorchu Apr 25, 2024
9389210
Ser/deser mweb bytes
hectorchu Apr 28, 2024
4f0750f
Merge remote-tracking branch 'origin/cake-update-v2' into cake-update-v3
May 6, 2024
cc99eed
Merge remote-tracking branch 'master/main' into cake-update-v3
May 6, 2024
3d11660
Merge branch 'cake-update-v3' of https://github.com/cake-tech/bitcoin…
fossephate May 29, 2024
52afd84
Merge branch 'cake-update-v3' of https://github.com/cake-tech/bitcoin…
fossephate May 29, 2024
945d2dd
Merge remote-tracking branch 'master/main' into cake-update-v4
Jul 12, 2024
6403ebc
feat: refactorings, add canReplaceByFee
Aug 2, 2024
0591461
Merge remote-tracking branch 'master/main' into cake-update-v4
Aug 2, 2024
593d9ce
Merge remote-tracking branch 'origin/cake-mweb' into cake-update-v4
Aug 2, 2024
8781dc1
fix: mweb addr
Aug 2, 2024
574486b
fix replace by fee boolean
OmarHatem28 Aug 10, 2024
ff2b10e
Merge branch 'sign_message_v' of https://github.com/cake-tech/bitcoin…
fossephate Aug 12, 2024
7d8cb65
fix address validation for mweb addresses
fossephate Aug 22, 2024
1f4f6f6
update hashLength to 66
fossephate Aug 22, 2024
bc49e3b
feat: improve regex
Sep 6, 2024
80a92fc
feat: general and silent payments utils
Sep 11, 2024
f577e83
fix: address to scripthash
Sep 11, 2024
ef6d556
Merge branch 'cake-update-v7' of https://github.com/cake-tech/bitcoin…
fossephate Sep 20, 2024
fc045a1
check if type is bitcoinoutput before accessing field
fossephate Sep 26, 2024
86969a1
fix: locktime cursor on fromRaw
Oct 30, 2024
a055115
feat: electrum and sp only changes
rafael-xmr Jul 2, 2025
545bcad
fix sp tests
OmarHatem28 Jul 2, 2025
46e5a2d
add dogecoin network support
Serhii-Borodenko Jul 18, 2025
490046a
fix: silence `SocketException: Write failed`
MrCyjaneK Sep 11, 2025
bda0e29
Merge pull request #11 from MrCyjaneK/cyjan-cake-update-v11-errors
OmarHatem28 Sep 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ We have integrated three APIs—Mempool, BlockCypher, and Electrum—into the pl
final publicKey = ECPublic.fromHex('.....');

// Generate a Pay-to-Public-Key-Hash (P2PKH) address from the public key.
final p2pkh = publicKey.toAddress();
final p2pkh = publicKey.toP2pkhAddress();

// Generate a Pay-to-Witness-Public-Key-Hash (P2WPKH) Segregated Witness (SegWit) address from the public key.
final p2wpkh = publicKey.toSegwitAddress();
final p2wpkh = publicKey.toP2wpkhAddress();

// Generate a Pay-to-Witness-Script-Hash (P2WSH) Segregated Witness (SegWit) address from the public key.
final p2wsh = publicKey.toP2wshAddress();
Expand Down Expand Up @@ -286,8 +286,8 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
final privateKey = ECPrivate.fromHex(
"76257aafc9b954351c7f6445b2d07277f681a5e83d515a1f32ebf54989c2af4f");
final examplePublicKey = privateKey.getPublic();
final spender1 = examplePublicKey.toAddress();
final spender2 = examplePublicKey.toSegwitAddress();
final spender1 = examplePublicKey.toP2pkhAddress();
final spender2 = examplePublicKey.toP2wpkhAddress();
final spender3 = examplePublicKey.toTaprootAddress();
final spender4 = examplePublicKey.toP2pkhInP2sh();
final spender5 = examplePublicKey.toP2pkInP2sh();
Expand Down Expand Up @@ -336,9 +336,9 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
/// P2pkhAddress.fromAddress(address: ".....", network: network);
/// P2trAddress.fromAddress(address: "....", network: network)
/// ....
final List<BitcoinOutput> outPuts = [
final List<BitcoinOutput> outputs = [
BitcoinOutput(
address: examplePublicKey2.toSegwitAddress(),
address: examplePublicKey2.toP2wpkhAddress(),
value: BtcUtils.toSatoshi("0.00001")),
BitcoinOutput(
address: examplePublicKey2.toTaprootAddress(),
Expand All @@ -365,11 +365,11 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
int transactionSize = BitcoinTransactionBuilder.estimateTransactionSize(
utxos: accountsUtxos,
outputs: [
...outPuts,
...outputs,

/// I add more output for change value to get correct transaction size
BitcoinOutput(
address: examplePublicKey2.toAddress(), value: BigInt.zero)
address: examplePublicKey2.toP2pkhAddress(), value: BigInt.zero)
],

/// network
Expand All @@ -396,13 +396,13 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
}
//// if we have change value we back amount to account
if (changeValue > BigInt.zero) {
outPuts.add(BitcoinOutput(
address: examplePublicKey2.toAddress(), value: changeValue));
outputs.add(BitcoinOutput(
address: examplePublicKey2.toP2pkhAddress(), value: changeValue));
}

/// create transaction builder
final builder = BitcoinTransactionBuilder(
outPuts: outPuts,
outputs: outputs,
fee: fee,
network: network,
utxos: accountsUtxos,
Expand Down Expand Up @@ -465,7 +465,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li

/// p2pkh with token address ()
final receiver1 = P2pkhAddress.fromHash160(
addrHash: publicKey.toAddress().addressProgram,
h160: publicKey.toP2pkhAddress().addressProgram,
type: P2pkhAddressType.p2pkhwt);

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
Expand Down Expand Up @@ -514,7 +514,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
previousValue + element.utxo.token!.amount);

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
/// change address for bch values (sum of bch amout - (outputs amount + fee))
BitcoinOutput(
address: p2pkhAddress.baseAddress,
Expand Down Expand Up @@ -678,7 +678,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
// index of utxo
txInIndex: i,
// spender script pub key
script: utxo[i].public().toAddress().toScriptPubKey(),
script: utxo[i].public().toP2pkhAddress().toScriptPubKey(),
);

// sign transaction
Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/burn_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ void main() async {

/// p2pkh with token address ()
final receiver1 = P2pkhAddress.fromHash160(
addrHash: publicKey.toAddress().addressProgram,
h160: publicKey.toP2pkhAddress().addressProgram,
type: P2pkhAddressType.p2pkhwt);

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
Expand Down Expand Up @@ -80,7 +80,7 @@ void main() async {
previousValue + element.utxo.token!.amount);

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
/// change address for bch values (sum of bch amout - (outputs amount + fee))
BitcoinOutput(
address: p2pkhAddress.baseAddress,
Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/create_cash_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ void main() async {

/// Derives a P2PKH address from the given public key and converts it to a Bitcoin Cash address
/// for enhanced accessibility within the network.
final p2pkhAddress = publicKey.toAddress();
final p2pkhAddress = publicKey.toP2pkhAddress();

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.pubKeyHash(),
Expand Down Expand Up @@ -66,7 +66,7 @@ void main() async {
// print("vout $vout0Hash");
// return;
final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
BitcoinTokenOutput(
address: p2pkhAddress,

Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/create_nft_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ void main() async {
/// Derives a P2PKH address from the given public key and converts it to a Bitcoin Cash address
/// for enhanced accessibility within the network.
final p2pkhAddress =
BitcoinCashAddress.fromBaseAddress(publicKey.toAddress());
BitcoinCashAddress.fromBaseAddress(publicKey.toP2pkhAddress());

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
Expand Down Expand Up @@ -65,7 +65,7 @@ void main() async {
return;
}
final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
BitcoinOutput(
address: p2pkhAddress.baseAddress,
value: sumOfUtxo -
Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/make_vout0_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ void main() async {

/// Derives a P2PKH address from the given public key and converts it to a Bitcoin Cash address
/// for enhanced accessibility within the network.
final p2pkhAddress = publicKey.toAddress();
final p2pkhAddress = publicKey.toP2pkhAddress();

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.pubKeyHash(),
Expand All @@ -47,7 +47,7 @@ void main() async {
final sumOfUtxo = utxos.sumOfUtxosValue();

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
BitcoinOutput(
address: p2pkhAddress,
value: sumOfUtxo - BtcUtils.toSatoshi("0.00003"),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/bitcoin_cash/minting_nft_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() async {
final p2pkhAddress = BitcoinCashAddress.fromBaseAddress(
publicKey.toP2pkInP2sh(useBCHP2sh32: true));

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
Expand All @@ -54,7 +54,7 @@ void main() async {
"3f0d87791e5996aaddbce16c12651dd8b5b881cf7338340504bb7b2c6c08bfc4";

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
BitcoinOutput(
address: p2pkhAddress.baseAddress,
value: sumOfUtxo -
Expand Down
16 changes: 8 additions & 8 deletions example/lib/bitcoin_cash/old_examples/old_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void _spendFrom2P2SHAnd2P2PKHAddress() async {
]);

final b = ForkedTransactionBuilder(
outPuts: [
outputs: [
/// Define a BitcoinOutput with the P2shAddress and a value of 0.01 BCH
BitcoinOutput(address: out1, value: BtcUtils.toSatoshi("0.01")),

Expand All @@ -121,7 +121,7 @@ void _spendFrom2P2SHAnd2P2PKHAddress() async {
/// Specify the network for the litcoin transaction
network: network,

/// Define a list of Unspent Transaction Outputs (UTXOs) for the Bitcoin transaction
/// Define a list of Unspent Transaction outputs (UTXOs) for the Bitcoin transaction
utxos: [
UtxoWithAddress(

Expand All @@ -138,13 +138,13 @@ void _spendFrom2P2SHAnd2P2PKHAddress() async {
vout: 0,

/// Script type indicates the type of script associated with the UTXO's address
scriptType: examplePublicKey2.toAddress().type,
scriptType: examplePublicKey2.toP2pkhAddress().type,
),

/// Include owner details with the public key and address associated with the UTXO
ownerDetails: UtxoAddressDetails(
publicKey: examplePublicKey2.toHex(),
address: examplePublicKey2.toAddress())),
address: examplePublicKey2.toP2pkhAddress())),
]);

/// Build the transaction by invoking the buildTransaction method on the ForkedTransactionBuilder
Expand Down Expand Up @@ -247,7 +247,7 @@ void _spendFrom2P2SHAnd1P2PKHAddress() async {
final b = ForkedTransactionBuilder(

/// outputs
outPuts: [
outputs: [
/// Define a BitcoinOutput with the P2pkhAddress and a value of 0.01 BCH
BitcoinOutput(address: out1, value: BtcUtils.toSatoshi("0.01")),

Expand All @@ -267,7 +267,7 @@ void _spendFrom2P2SHAnd1P2PKHAddress() async {
/// Add a memo to the transaction, linking to the GitHub repository
memo: "https://github.com/mrtnetwork",

/// Define a list of Unspent Transaction Outputs (UTXOs) for the Bitcoin transaction
/// Define a list of Unspent Transaction outputs (UTXOs) for the Bitcoin transaction
utxos: [
UtxoWithAddress(

Expand Down Expand Up @@ -324,13 +324,13 @@ void _spendFrom2P2SHAnd1P2PKHAddress() async {
vout: 2,

/// Script type indicates the type of script associated with the UTXO's address
scriptType: examplePublicKey.toAddress().type,
scriptType: examplePublicKey.toP2pkhAddress().type,
),

/// Include owner details with the public key and address associated with the UTXO
ownerDetails: UtxoAddressDetails(
publicKey: examplePublicKey.toHex(),
address: examplePublicKey.toAddress())),
address: examplePublicKey.toP2pkhAddress())),
UtxoWithAddress(
utxo: BitcoinUtxo(
/// Transaction hash uniquely identifies the referenced transaction
Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/p2sh32_spend_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() async {
/// Derives a P2PKH address from the given public key and converts it to a Bitcoin Cash address
/// for enhanced accessibility within the network.
final p2pkhAddress =
BitcoinCashAddress.fromBaseAddress(publicKey.toAddress());
BitcoinCashAddress.fromBaseAddress(publicKey.toP2pkhAddress());

/// Initialize two P2SH32 addresses for receiving funds.
/// bchtest:pvw39llgap0a4vm8jn9sjsvfsthah4wgemjlh6epdtzr3pl2fqtmsn3s4vcm7
Expand All @@ -42,7 +42,7 @@ void main() async {
final p2sh32Example2 = BitcoinCashAddress.fromBaseAddress(
publicKey.toP2pkInP2sh(useBCHP2sh32: true));

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final example1ElectrumUtxos =
await provider.request(ElectrumScriptHashListUnspent(
Expand Down Expand Up @@ -79,7 +79,7 @@ void main() async {
return;
}
final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
BitcoinOutput(
address: p2pkhAddress.baseAddress,
value: BtcUtils.toSatoshi("0.00001"),
Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/send_ft_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ void main() async {

/// p2pkh with token address ()
final receiver1 = P2pkhAddress.fromHash160(
addrHash: publicKey.toAddress().addressProgram,
h160: publicKey.toP2pkhAddress().addressProgram,
type: P2pkhAddressType.p2pkhwt);

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
Expand Down Expand Up @@ -80,7 +80,7 @@ void main() async {
previousValue + element.utxo.token!.amount);

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
/// change address for bch values (sum of bch amout - (outputs amount + fee))
BitcoinOutput(
address: p2pkhAddress.baseAddress,
Expand Down
6 changes: 3 additions & 3 deletions example/lib/bitcoin_cash/transfer_bch_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() async {
/// Derives a P2PKH address from the given public key and converts it to a Bitcoin Cash address
/// for enhanced accessibility within the network.
final p2pkhAddress =
BitcoinCashAddress.fromBaseAddress(publicKey.toAddress());
BitcoinCashAddress.fromBaseAddress(publicKey.toP2pkhAddress());

/// Initialize two P2SH32 addresses for receiving funds.
final p2sh32Example1 = BitcoinCashAddress(
Expand All @@ -37,7 +37,7 @@ void main() async {
"bchtest:pvw39llgap0a4vm8jn9sjsvfsthah4wgemjlh6epdtzr3pl2fqtmsn3s4vcm7",
network: network);

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
Expand All @@ -59,7 +59,7 @@ void main() async {
}

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
/// change input (sumofutxos - spend)
BitcoinOutput(
address: p2pkhAddress.baseAddress,
Expand Down
6 changes: 3 additions & 3 deletions example/lib/global/bch_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() async {
/// Derives a P2PKH address from the given public key and converts it to a Bitcoin Cash address
/// for enhanced accessibility within the network.
final p2pkhAddress =
BitcoinCashAddress.fromBaseAddress(publicKey.toAddress());
BitcoinCashAddress.fromBaseAddress(publicKey.toP2pkhAddress());

/// Initialize two P2SH32 addresses for receiving funds.
final p2sh32Example1 = BitcoinCashAddress(
Expand All @@ -34,7 +34,7 @@ void main() async {
"bchtest:pvw39llgap0a4vm8jn9sjsvfsthah4wgemjlh6epdtzr3pl2fqtmsn3s4vcm7",
network: network);

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// Reads all UTXOs (Unspent Transaction outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
Expand All @@ -56,7 +56,7 @@ void main() async {
}

final bchTransaction = ForkedTransactionBuilder(
outPuts: [
outputs: [
/// change input (sumofutxos - spend)
BitcoinOutput(
address: p2pkhAddress.baseAddress,
Expand Down
Loading