-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
133b199
commit fe59610
Showing
60 changed files
with
46,477 additions
and
73,984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
on: | ||
push: | ||
branches: [v1.0.0-alpha.11, master, main] | ||
branches: [0.31.2, master, main] | ||
|
||
name: Precompile Binaries | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import 'package:bdk_flutter_example/wallet.dart'; | ||
import 'package:bdk_flutter_example/simple_wallet.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
void main() { | ||
runApp(const BdkWallet()); | ||
runApp(const SimpleWallet()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'package:bdk_flutter/bdk_flutter.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
|
||
class MultiSigWallet { | ||
Future<List<Descriptor>> init2Of3Descriptors(List<Mnemonic> mnemonics) async { | ||
final List<DescriptorKeyInfo> descriptorInfos = []; | ||
for (var e in mnemonics) { | ||
final secret = await DescriptorSecretKey.create( | ||
network: Network.testnet, mnemonic: e); | ||
final public = secret.toPublic(); | ||
descriptorInfos.add(DescriptorKeyInfo(secret, public)); | ||
} | ||
final alice = | ||
"wsh(sortedmulti(2,${descriptorInfos[0].xprv},${descriptorInfos[1].xpub},${descriptorInfos[2].xpub}))"; | ||
final bob = | ||
"wsh(sortedmulti(2,${descriptorInfos[1].xprv},${descriptorInfos[2].xpub},${descriptorInfos[0].xpub}))"; | ||
final dave = | ||
"wsh(sortedmulti(2,${descriptorInfos[2].xprv},${descriptorInfos[0].xpub},${descriptorInfos[1].xpub}))"; | ||
final List<Descriptor> descriptors = []; | ||
final parsedDes = [alice, bob, dave]; | ||
for (var e in parsedDes) { | ||
final res = | ||
await Descriptor.create(descriptor: e, network: Network.testnet); | ||
descriptors.add(res); | ||
} | ||
return descriptors; | ||
} | ||
|
||
Future<List<Descriptor>> createDescriptors() async { | ||
final alice = await Mnemonic.fromString( | ||
'thumb member wage display inherit music elevator need side setup tube panther broom giant auction banner split potato'); | ||
final bob = await Mnemonic.fromString( | ||
'tired shine hat tired hover timber reward bridge verb aerobic safe economy'); | ||
final dave = await Mnemonic.fromString( | ||
'lawsuit upper gospel minimum cinnamon common boss wage benefit betray ribbon hour'); | ||
final descriptors = await init2Of3Descriptors([alice, bob, dave]); | ||
return descriptors; | ||
} | ||
|
||
Future<List<Wallet>> init20f3Wallets() async { | ||
final descriptors = await createDescriptors(); | ||
final alice = await Wallet.create( | ||
descriptor: descriptors[0], | ||
network: Network.testnet, | ||
databaseConfig: const DatabaseConfig.memory()); | ||
final bob = await Wallet.create( | ||
descriptor: descriptors[1], | ||
network: Network.testnet, | ||
databaseConfig: const DatabaseConfig.memory()); | ||
final dave = await Wallet.create( | ||
descriptor: descriptors[2], | ||
network: Network.testnet, | ||
databaseConfig: const DatabaseConfig.memory()); | ||
return [alice, bob, dave]; | ||
} | ||
|
||
sendBitcoin(Blockchain blockchain, Wallet wallet, Wallet bobWallet, | ||
String addressStr) async { | ||
try { | ||
final txBuilder = TxBuilder(); | ||
final address = | ||
await Address.fromString(s: addressStr, network: wallet.network()); | ||
final script = address.scriptPubkey(); | ||
final feeRate = await blockchain.estimateFee(target: BigInt.from(25)); | ||
final (psbt, _) = await txBuilder | ||
.addRecipient(script, BigInt.from(1200)) | ||
.feeRate(feeRate.satPerVb) | ||
.finish(wallet); | ||
await wallet.sign( | ||
psbt: psbt, | ||
signOptions: const SignOptions( | ||
trustWitnessUtxo: false, | ||
allowAllSighashes: true, | ||
removePartialSigs: true, | ||
tryFinalize: true, | ||
signWithTapInternalKey: true, | ||
allowGrinding: true)); | ||
final isFinalized = await bobWallet.sign(psbt: psbt); | ||
if (isFinalized) { | ||
final tx = psbt.extractTx(); | ||
await blockchain.broadcast(transaction: tx); | ||
} else { | ||
debugPrint("Psbt not finalized!"); | ||
} | ||
} on FormatException catch (e) { | ||
if (kDebugMode) { | ||
print(e.message); | ||
} | ||
} | ||
} | ||
} | ||
|
||
class DescriptorKeyInfo { | ||
final DescriptorSecretKey xprv; | ||
final DescriptorPublicKey xpub; | ||
DescriptorKeyInfo(this.xprv, this.xpub); | ||
} |
Oops, something went wrong.