Skip to content

Commit

Permalink
Get app to build on main
Browse files Browse the repository at this point in the history
  • Loading branch information
J0J0XMR committed Dec 17, 2024
1 parent b38a61b commit 24482a2
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 117 deletions.
4 changes: 0 additions & 4 deletions cw_bitcoin/lib/bitcoin_payjoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ export 'package:payjoin_flutter/send.dart' show Sender;

export 'package:payjoin_flutter/src/exceptions.dart' show PayjoinException;

import 'package:ledger_bitcoin/src/psbt/psbt_extractor.dart';

import 'psbt_converter.dart';

class BitcoinPayjoin {
// Private constructor
BitcoinPayjoin._internal();
Expand Down
1 change: 0 additions & 1 deletion cw_bitcoin/lib/psbt_signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:ledger_bitcoin/psbt.dart';
import 'package:ledger_bitcoin/src/psbt/constants.dart';
import 'psbt_converter.dart';

extension PsbtSigner on PsbtV2 {
void sign(List<UtxoWithAddress> utxos, BitcoinSignerCallBack signer) {
Expand Down
57 changes: 44 additions & 13 deletions lib/bitcoin/bitcoin.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import 'dart:io' show Platform;
import 'dart:typed_data';
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart';
import 'package:cake_wallet/view_model/send/output.dart';
import 'package:cw_bitcoin/bitcoin_payjoin.dart';
import 'package:cw_core/hardware/hardware_account_data.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/output_info.dart';
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/receive_page_option.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/unspent_coin_type.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_core/unspent_transaction_output.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_credentials.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_service.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/get_height_by_date.dart';
import 'package:hive/hive.dart';
import 'package:ledger_flutter/ledger_flutter.dart';
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:bip39/bip39.dart' as bip39;

Expand All @@ -26,7 +30,9 @@ import 'package:cw_bitcoin/electrum_derivations.dart';
import 'package:cw_bitcoin/electrum.dart';
import 'package:cw_bitcoin/pending_bitcoin_transaction.dart';
import 'package:cw_bitcoin/bitcoin_receive_page_option.dart';
import 'package:cw_bitcoin/bitcoin_payjoin.dart';
import 'package:cw_bitcoin/bitcoin_wallet.dart';
import 'package:cw_bitcoin/electrum_transaction_info.dart';
import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_bitcoin/bitcoin_unspent.dart';
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
Expand All @@ -36,9 +42,11 @@ import 'package:cw_bitcoin/bitcoin_wallet_creation_credentials.dart';
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
import 'package:cw_bitcoin/bitcoin_address_record.dart';
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
import 'package:cw_bitcoin/litecoin_wallet.dart';
import 'package:cw_bitcoin/litecoin_wallet_service.dart';
import 'package:cw_core/get_height_by_date.dart';
import 'package:cw_bitcoin/bitcoin_hardware_wallet_service.dart';
import 'package:cw_bitcoin/litecoin_hardware_wallet_service.dart';
import 'package:mobx/mobx.dart';

part 'cw_bitcoin.dart';
Expand Down Expand Up @@ -78,7 +86,12 @@ abstract class Bitcoin {
required String wif,
WalletInfo? walletInfo});
WalletCredentials createBitcoinNewWalletCredentials(
{required String name, WalletInfo? walletInfo, String? password});
{required String name,
WalletInfo? walletInfo,
String? password,
String? passphrase,
String? mnemonic,
String? parentAddress});
WalletCredentials createBitcoinHardwareWalletCredentials(
{required String name,
required HardwareAccountData accountData,
Expand All @@ -93,9 +106,9 @@ abstract class Bitcoin {
Future<void> generateNewAddress(Object wallet, String label);
Future<void> updateAddress(Object wallet, String address, String label);
Object createBitcoinTransactionCredentials(List<Output> outputs,
{required TransactionPriority priority, int? feeRate});
Object createBitcoinTransactionCredentialsRaw(List<OutputInfo> outputs,
{TransactionPriority? priority, required int feeRate});
{required TransactionPriority priority,
int? feeRate,
UnspentCoinType coinTypeToSpendFrom = UnspentCoinType.any});

String getAddress(Object wallet);
List<ElectrumSubAddress> getSilentPaymentAddresses(Object wallet);
Expand All @@ -112,12 +125,13 @@ abstract class Bitcoin {
TransactionPriority priority, int rate,
{int? customRate});

List<Unspent> getUnspents(Object wallet);
List<Unspent> getUnspents(Object wallet,
{UnspentCoinType coinTypeToSpendFrom = UnspentCoinType.any});
Future<void> updateUnspents(Object wallet);
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource,
Box<UnspentCoinsInfo> unspentCoinSource, bool alwaysScan, bool isDirect);
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource,
Box<UnspentCoinsInfo> unspentCoinSource, bool isDirect);
Box<UnspentCoinsInfo> unspentCoinSource, bool alwaysScan, bool isDirect);
TransactionPriority getBitcoinTransactionPriorityMedium();
TransactionPriority getBitcoinTransactionPriorityCustom();
TransactionPriority getLitecoinTransactionPriorityMedium();
Expand All @@ -131,6 +145,7 @@ abstract class Bitcoin {
Future<void> setAddressType(Object wallet, dynamic option);
ReceivePageOption getSelectedAddressType(Object wallet);
List<ReceivePageOption> getBitcoinReceivePageOptions();
List<ReceivePageOption> getLitecoinReceivePageOptions();
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option);
bool hasSelectedSilentPayments(Object wallet);
bool isBitcoinReceivePageOption(ReceivePageOption option);
Expand All @@ -142,7 +157,8 @@ abstract class Bitcoin {

Future<PendingTransaction> replaceByFee(
Object wallet, String transactionHash, String fee);
Future<bool> canReplaceByFee(Object wallet, String transactionHash);
Future<String?> canReplaceByFee(Object wallet, Object tx);
int getTransactionVSize(Object wallet, String txHex);
Future<bool> isChangeSufficientForFee(
Object wallet, String txId, String newFee);
int getFeeAmountForPriority(Object wallet, TransactionPriority priority,
Expand All @@ -153,18 +169,33 @@ abstract class Bitcoin {
int feeAmountWithFeeRate(
Object wallet, int feeRate, int inputsCount, int outputsCount,
{int? size});
int getHeightByDate({required DateTime date});
Future<bool> checkIfMempoolAPIIsEnabled(Object wallet);
Future<int> getHeightByDate(
{required DateTime date, bool? bitcoinMempoolAPIEnabled});
int getLitecoinHeightByDate({required DateTime date});
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
Future<bool> getNodeIsElectrsSPEnabled(Object wallet);
void deleteSilentPaymentAddress(Object wallet, String address);
Future<void> updateFeeRates(Object wallet);
int getMaxCustomFeeRate(Object wallet);

void setLedger(WalletBase wallet, Ledger ledger, LedgerDevice device);
Future<List<HardwareAccountData>> getHardwareWalletAccounts(
void setLedgerConnection(
WalletBase wallet, ledger.LedgerConnection connection);
Future<List<HardwareAccountData>> getHardwareWalletBitcoinAccounts(
LedgerViewModel ledgerVM,
{int index = 0,
int limit = 5});
Future<List<HardwareAccountData>> getHardwareWalletLitecoinAccounts(
LedgerViewModel ledgerVM,
{int index = 0,
int limit = 5});
List<Output> updateOutputs(
PendingTransaction pendingTransaction, List<Output> outputs);
bool txIsReceivedSilentPayment(TransactionInfo txInfo);
bool txIsMweb(TransactionInfo txInfo);
Future<void> setMwebEnabled(Object wallet, bool enabled);
bool getMwebEnabled(Object wallet);
String? getUnusedMwebAddress(Object wallet);
String? getUnusedSegwitAddress(Object wallet);

Future<Map<String, dynamic>> buildV2PjStr({
int? amount,
Expand Down
197 changes: 98 additions & 99 deletions lib/bitcoin/cw_bitcoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -752,116 +752,115 @@ class CWBitcoin extends Bitcoin {
} catch (_) {
return null;
}
}

Future<Map<String, dynamic>> buildV2PjStr({
int? amount,
required String address,
required bool isTestnet,
required BigInt expireAfter,
}) async {
final res = await payjoin.buildV2PjStr(
amount: amount,
address: address,
network: isTestnet ? payjoin.testnet : payjoin.mainnet,
expireAfter: expireAfter,
);
return res;
}
Future<Map<String, dynamic>> buildV2PjStr({
int? amount,
required String address,
required bool isTestnet,
required BigInt expireAfter,
}) async {
final res = await payjoin.buildV2PjStr(
amount: amount,
address: address,
network: isTestnet ? payjoin.testnet : payjoin.mainnet,
expireAfter: expireAfter,
);
return res;
}

@override
Future<UncheckedProposal> handleReceiverSession(Receiver session) async {
final res = await payjoin.handleReceiverSession(session);
return res;
}
@override
Future<UncheckedProposal> handleReceiverSession(Receiver session) async {
final res = await payjoin.handleReceiverSession(session);
return res;
}

@override
Future<String> extractOriginalTransaction(
UncheckedProposal proposal) async {
final res = await payjoin.extractOriginalTransaction(proposal);
return res;
}
@override
Future<String> extractOriginalTransaction(UncheckedProposal proposal) async {
final res = await payjoin.extractOriginalTransaction(proposal);
return res;
}

@override
Future<PayjoinProposal> processProposal({
required UncheckedProposal proposal,
required Object receiverWallet,
}) async {
final res = await payjoin.processProposal(
proposal: proposal, receiverWallet: receiverWallet);
return res;
}
@override
Future<PayjoinProposal> processProposal({
required UncheckedProposal proposal,
required Object receiverWallet,
}) async {
final res = await payjoin.processProposal(
proposal: proposal, receiverWallet: receiverWallet);
return res;
}

@override
Future<String> sendFinalProposal(PayjoinProposal finalProposal) async {
final res = await payjoin.sendFinalProposal(finalProposal);
return res;
}
@override
Future<String> sendFinalProposal(PayjoinProposal finalProposal) async {
final res = await payjoin.sendFinalProposal(finalProposal);
return res;
}

@override
Future<String> getTxIdFromPsbt(String psbtBase64) async {
final res = await payjoin.getTxIdFromPsbt(psbtBase64);
return res;
}
@override
Future<String> getTxIdFromPsbt(String psbtBase64) async {
final res = await payjoin.getTxIdFromPsbt(psbtBase64);
return res;
}

@override
Future<Uri?> stringToPjUri(String pj) async {
return await payjoin.stringToPjUri(pj);
}
@override
Future<Uri?> stringToPjUri(String pj) async {
return await payjoin.stringToPjUri(pj);
}

@override
Future<String> buildOriginalPsbt(
Object wallet,
dynamic pjUri,
int fee,
double amount,
Object credentials,
) async {
final res = await payjoin.buildOriginalPsbt(
wallet,
pjUri,
fee,
amount,
isTestnet(wallet),
credentials,
);
@override
Future<String> buildOriginalPsbt(
Object wallet,
dynamic pjUri,
int fee,
double amount,
Object credentials,
) async {
final res = await payjoin.buildOriginalPsbt(
wallet,
pjUri,
fee,
amount,
isTestnet(wallet),
credentials,
);

return res;
}
return res;
}

@override
Future<Sender> buildPayjoinRequest(
String originalPsbt,
dynamic pjUri,
int fee,
) async {
final res = await payjoin.buildPayjoinRequest(
originalPsbt,
pjUri,
fee,
);
return res;
}
@override
Future<Sender> buildPayjoinRequest(
String originalPsbt,
dynamic pjUri,
int fee,
) async {
final res = await payjoin.buildPayjoinRequest(
originalPsbt,
pjUri,
fee,
);
return res;
}

@override
Future<String> requestAndPollV2Proposal(
Sender sender,
) async {
final res = await payjoin.requestAndPollV2Proposal(sender);
return res;
}
@override
Future<String> requestAndPollV2Proposal(
Sender sender,
) async {
final res = await payjoin.requestAndPollV2Proposal(sender);
return res;
}

@override
Future<PendingBitcoinTransaction> extractPjTx(
Object wallet,
String psbtString,
Object credentials,
) async {
final res = await payjoin.extractPjTx(
wallet,
psbtString,
credentials,
);
return res;
}
@override
Future<PendingBitcoinTransaction> extractPjTx(
Object wallet,
String psbtString,
Object credentials,
) async {
final res = await payjoin.extractPjTx(
wallet,
psbtString,
credentials,
);
return res;
}
}

0 comments on commit 24482a2

Please sign in to comment.