2021-12-24 12:52:08 +00:00
|
|
|
part of 'bitcoin.dart';
|
|
|
|
|
|
|
|
class CWBitcoin extends Bitcoin {
|
|
|
|
@override
|
|
|
|
TransactionPriority getMediumTransactionPriority() => BitcoinTransactionPriority.medium;
|
|
|
|
|
|
|
|
@override
|
|
|
|
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials({String name, String mnemonic, String password})
|
|
|
|
=> BitcoinRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password);
|
|
|
|
|
|
|
|
@override
|
|
|
|
WalletCredentials createBitcoinRestoreWalletFromWIFCredentials({String name, String password, String wif, WalletInfo walletInfo})
|
|
|
|
=> BitcoinRestoreWalletFromWIFCredentials(name: name, password: password, wif: wif, walletInfo: walletInfo);
|
|
|
|
|
|
|
|
@override
|
|
|
|
WalletCredentials createBitcoinNewWalletCredentials({String name, WalletInfo walletInfo})
|
|
|
|
=> BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<String> getWordList() => wordlist;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, String> getWalletKeys(Object wallet) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
final keys = bitcoinWallet.keys;
|
|
|
|
|
|
|
|
return <String, String>{
|
|
|
|
'wif': keys.wif,
|
|
|
|
'privateKey': keys.privateKey,
|
|
|
|
'publicKey': keys.publicKey
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<TransactionPriority> getTransactionPriorities()
|
|
|
|
=> BitcoinTransactionPriority.all;
|
|
|
|
|
2022-01-12 16:13:16 +00:00
|
|
|
List<TransactionPriority> getLitecoinTransactionPriorities()
|
|
|
|
=> LitecoinTransactionPriority.all;
|
|
|
|
|
2021-12-24 12:52:08 +00:00
|
|
|
@override
|
|
|
|
TransactionPriority deserializeBitcoinTransactionPriority(int raw)
|
|
|
|
=> BitcoinTransactionPriority.deserialize(raw: raw);
|
|
|
|
|
|
|
|
@override
|
|
|
|
int getFeeRate(Object wallet, TransactionPriority priority) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
return bitcoinWallet.feeRate(priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> generateNewAddress(Object wallet) async {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
await bitcoinWallet.walletAddresses.generateNewAddress();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> nextAddress(Object wallet) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2022-01-18 16:27:33 +00:00
|
|
|
bitcoinWallet.walletAddresses.nextReceiveAddress();
|
2021-12-24 12:52:08 +00:00
|
|
|
}
|
2022-01-12 13:20:43 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> randomAddress(Object wallet) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2022-01-12 13:20:43 +00:00
|
|
|
bitcoinWallet.walletAddresses.randomizeAddress();
|
|
|
|
}
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Object createBitcoinTransactionCredentials(List<Output> outputs, TransactionPriority priority)
|
|
|
|
=> BitcoinTransactionCredentials(
|
|
|
|
outputs.map((out) => OutputInfo(
|
|
|
|
fiatAmount: out.fiatAmount,
|
|
|
|
cryptoAmount: out.cryptoAmount,
|
|
|
|
address: out.address,
|
|
|
|
note: out.note,
|
|
|
|
sendAll: out.sendAll,
|
|
|
|
extractedAddress: out.extractedAddress,
|
|
|
|
isParsedAddress: out.isParsedAddress,
|
|
|
|
formattedCryptoAmount: out.formattedCryptoAmount))
|
|
|
|
.toList(),
|
|
|
|
priority as BitcoinTransactionPriority);
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<String> getAddresses(Object wallet) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
return bitcoinWallet.walletAddresses.addresses
|
|
|
|
.map((BitcoinAddressRecord addr) => addr.address)
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String getAddress(Object wallet) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
return bitcoinWallet.walletAddresses.address;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String formatterBitcoinAmountToString({int amount})
|
|
|
|
=> bitcoinAmountToString(amount: amount);
|
|
|
|
|
|
|
|
@override
|
|
|
|
double formatterBitcoinAmountToDouble({int amount})
|
|
|
|
=> bitcoinAmountToDouble(amount: amount);
|
|
|
|
|
|
|
|
@override
|
|
|
|
int formatterStringDoubleToBitcoinAmount(String amount)
|
|
|
|
=> stringDoubleToBitcoinAmount(amount);
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<Unspent> getUnspents(Object wallet) {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
return bitcoinWallet.unspentCoins
|
|
|
|
.map((BitcoinUnspent bitcoinUnspent) => Unspent(
|
|
|
|
bitcoinUnspent.address.address,
|
|
|
|
bitcoinUnspent.hash,
|
|
|
|
bitcoinUnspent.value,
|
|
|
|
bitcoinUnspent.vout))
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateUnspents(Object wallet) async {
|
2022-01-12 13:33:56 +00:00
|
|
|
final bitcoinWallet = wallet as ElectrumWallet;
|
2021-12-24 12:52:08 +00:00
|
|
|
await bitcoinWallet.updateUnspent();
|
|
|
|
}
|
|
|
|
|
|
|
|
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
|
|
|
|
return BitcoinWalletService(walletInfoSource, unspentCoinSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
|
|
|
|
return LitecoinWalletService(walletInfoSource, unspentCoinSource);
|
|
|
|
}
|
|
|
|
}
|