Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 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
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
933406d
fix: litecoin address type regexes
Mar 19, 2024
7a3d202
Update dependencies
mrtnetwork Feb 27, 2024
9873c65
Update electrum_api_provider.dart
mrtnetwork Feb 27, 2024
2bd0408
v4.2.0
mrtnetwork Mar 16, 2024
d21f1fe
Update dependencies
mrtnetwork Apr 20, 2024
40acd2b
update mempool api
mrtnetwork Apr 30, 2024
2935394
Update dart.yml
mrtnetwork Apr 30, 2024
54315ba
Update dart.yml
mrtnetwork Apr 30, 2024
8a61ec2
Update dart.yml
mrtnetwork Apr 30, 2024
8ac3d66
Update dart.yml
mrtnetwork Apr 30, 2024
5f45e4a
Update dart.yml
mrtnetwork Apr 30, 2024
aa0c93c
Update dart.yml
mrtnetwork Apr 30, 2024
efb4d0a
Update dart.yml
mrtnetwork Apr 30, 2024
92386d6
Update dependencies
mrtnetwork May 30, 2024
4040787
flutter lints
mrtnetwork May 30, 2024
64d438d
v4.4.0
mrtnetwork Jun 15, 2024
ad168a4
V4.5.0
mrtnetwork Jun 24, 2024
54312a4
v4.6.0
mrtnetwork Jul 5, 2024
6509df4
feat: refactorings, add canReplaceByFee
Aug 2, 2024
c2b7d58
V4.7.0
mrtnetwork Jul 14, 2024
3ce822b
update pubspec
mrtnetwork Jul 14, 2024
3358bf8
Support MWEB addresses
hectorchu Apr 22, 2024
213f933
Stubs for MWEB
hectorchu Apr 24, 2024
a9363a1
Fix mweb scriptpubkey
hectorchu Apr 25, 2024
7f4803b
Fix mweb address detection
hectorchu Apr 25, 2024
6ac35af
fix: mweb addr
Aug 2, 2024
340384a
fix replace by fee boolean
OmarHatem28 Aug 10, 2024
8a4879e
signing updates
fossephate Apr 22, 2024
335c969
fix address validation for mweb addresses
fossephate Aug 22, 2024
c9f4b47
update hashLength to 66
fossephate Aug 22, 2024
444027d
feat: improve regex
Sep 6, 2024
63de342
feat: general and silent payments utils
Sep 11, 2024
d0dd983
fix: address to scripthash
Sep 11, 2024
f0fe403
rename package to old
OmarHatem28 May 29, 2025
2ddd195
Revert "rename package to old"
OmarHatem28 May 29, 2025
9bd6cab
Merge branch 'main' of https://github.com/cake-tech/bitcoin_base into…
OmarHatem28 Jun 24, 2025
38fe830
fix tests
OmarHatem28 Jun 24, 2025
0aef626
fix tests
OmarHatem28 Jun 25, 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 @@ -161,10 +161,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 @@ -303,8 +303,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 @@ -353,9 +353,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 @@ -382,11 +382,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 @@ -413,13 +413,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 @@ -482,7 +482,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 @@ -531,7 +531,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 @@ -695,7 +695,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(ElectrumRequestScriptHashListUnspent(
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(ElectrumRequestScriptHashListUnspent(
Expand Down Expand Up @@ -65,7 +65,7 @@ void main() async {
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(ElectrumRequestScriptHashListUnspent(
Expand Down Expand Up @@ -66,7 +66,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(ElectrumRequestScriptHashListUnspent(
Expand All @@ -48,7 +48,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(ElectrumRequestScriptHashListUnspent(
Expand All @@ -55,7 +55,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(ElectrumRequestScriptHashListUnspent(
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(ElectrumRequestScriptHashListUnspent(
Expand Down Expand Up @@ -81,7 +81,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(ElectrumRequestScriptHashListUnspent(
Expand All @@ -60,7 +60,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(ElectrumRequestScriptHashListUnspent(
Expand All @@ -57,7 +57,7 @@ void main() async {
}

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