mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
apply some changes from SP Fix pr
This commit is contained in:
parent
1da1f02a34
commit
d2f0a97764
15 changed files with 99 additions and 101 deletions
|
@ -17,21 +17,16 @@ BitcoinBaseAddress addressFromScript(Script script,
|
|||
|
||||
switch (addressType) {
|
||||
case P2pkhAddressType.p2pkh:
|
||||
return P2pkhAddress.fromScriptPubkey(
|
||||
script: script, network: BitcoinNetwork.mainnet);
|
||||
return P2pkhAddress.fromScriptPubkey(script: script);
|
||||
case P2shAddressType.p2pkhInP2sh:
|
||||
case P2shAddressType.p2pkInP2sh:
|
||||
return P2shAddress.fromScriptPubkey(
|
||||
script: script, network: BitcoinNetwork.mainnet);
|
||||
case SegwitAddresType.p2wpkh:
|
||||
return P2wpkhAddress.fromScriptPubkey(
|
||||
script: script, network: BitcoinNetwork.mainnet);
|
||||
case SegwitAddresType.p2wsh:
|
||||
return P2wshAddress.fromScriptPubkey(
|
||||
script: script, network: BitcoinNetwork.mainnet);
|
||||
case SegwitAddresType.p2tr:
|
||||
return P2trAddress.fromScriptPubkey(
|
||||
script: script, network: BitcoinNetwork.mainnet);
|
||||
return P2shAddress.fromScriptPubkey(script: script);
|
||||
case SegwitAddressType.p2wpkh:
|
||||
return P2wpkhAddress.fromScriptPubkey(script: script);
|
||||
case SegwitAddressType.p2wsh:
|
||||
return P2wshAddress.fromScriptPubkey(script: script);
|
||||
case SegwitAddressType.p2tr:
|
||||
return P2trAddress.fromScriptPubkey(script: script);
|
||||
}
|
||||
|
||||
throw ArgumentError("Invalid script");
|
||||
|
|
|
@ -82,7 +82,7 @@ class BitcoinAddressRecord extends BaseBitcoinAddressRecord {
|
|||
type: decoded['type'] != null && decoded['type'] != ''
|
||||
? BitcoinAddressType.values
|
||||
.firstWhere((type) => type.toString() == decoded['type'] as String)
|
||||
: SegwitAddresType.p2wpkh,
|
||||
: SegwitAddressType.p2wpkh,
|
||||
scriptHash: decoded['scriptHash'] as String?,
|
||||
network: network,
|
||||
);
|
||||
|
|
|
@ -36,9 +36,9 @@ class BitcoinReceivePageOption implements ReceivePageOption {
|
|||
BitcoinAddressType toType() {
|
||||
switch (this) {
|
||||
case BitcoinReceivePageOption.p2tr:
|
||||
return SegwitAddresType.p2tr;
|
||||
return SegwitAddressType.p2tr;
|
||||
case BitcoinReceivePageOption.p2wsh:
|
||||
return SegwitAddresType.p2wsh;
|
||||
return SegwitAddressType.p2wsh;
|
||||
case BitcoinReceivePageOption.p2pkh:
|
||||
return P2pkhAddressType.p2pkh;
|
||||
case BitcoinReceivePageOption.p2sh:
|
||||
|
@ -46,20 +46,20 @@ class BitcoinReceivePageOption implements ReceivePageOption {
|
|||
case BitcoinReceivePageOption.silent_payments:
|
||||
return SilentPaymentsAddresType.p2sp;
|
||||
case BitcoinReceivePageOption.mweb:
|
||||
return SegwitAddresType.mweb;
|
||||
return SegwitAddressType.mweb;
|
||||
case BitcoinReceivePageOption.p2wpkh:
|
||||
default:
|
||||
return SegwitAddresType.p2wpkh;
|
||||
return SegwitAddressType.p2wpkh;
|
||||
}
|
||||
}
|
||||
|
||||
factory BitcoinReceivePageOption.fromType(BitcoinAddressType type) {
|
||||
switch (type) {
|
||||
case SegwitAddresType.p2tr:
|
||||
case SegwitAddressType.p2tr:
|
||||
return BitcoinReceivePageOption.p2tr;
|
||||
case SegwitAddresType.p2wsh:
|
||||
case SegwitAddressType.p2wsh:
|
||||
return BitcoinReceivePageOption.p2wsh;
|
||||
case SegwitAddresType.mweb:
|
||||
case SegwitAddressType.mweb:
|
||||
return BitcoinReceivePageOption.mweb;
|
||||
case P2pkhAddressType.p2pkh:
|
||||
return BitcoinReceivePageOption.p2pkh;
|
||||
|
@ -67,7 +67,7 @@ class BitcoinReceivePageOption implements ReceivePageOption {
|
|||
return BitcoinReceivePageOption.p2sh;
|
||||
case SilentPaymentsAddresType.p2sp:
|
||||
return BitcoinReceivePageOption.silent_payments;
|
||||
case SegwitAddresType.p2wpkh:
|
||||
case SegwitAddressType.p2wpkh:
|
||||
default:
|
||||
return BitcoinReceivePageOption.p2wpkh;
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
|||
final psbt = PsbtV2()..deserializeV0(base64Decode(preProcessedPsbt));
|
||||
|
||||
await psbt.signWithUTXO(utxos, (txDigest, utxo, key, sighash) {
|
||||
return utxo.utxo.isP2tr()
|
||||
return utxo.utxo.isP2tr
|
||||
? key.signTapRoot(
|
||||
txDigest,
|
||||
sighash: sighash,
|
||||
|
|
|
@ -45,10 +45,10 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
|
|||
if (addressType == P2pkhAddressType.p2pkh)
|
||||
return generateP2PKHAddress(hd: hd, index: index, network: network);
|
||||
|
||||
if (addressType == SegwitAddresType.p2tr)
|
||||
if (addressType == SegwitAddressType.p2tr)
|
||||
return generateP2TRAddress(hd: hd, index: index, network: network);
|
||||
|
||||
if (addressType == SegwitAddresType.p2wsh)
|
||||
if (addressType == SegwitAddressType.p2wsh)
|
||||
return generateP2WSHAddress(hd: hd, index: index, network: network);
|
||||
|
||||
if (addressType == P2shAddressType.p2wpkhInP2sh)
|
||||
|
|
|
@ -182,7 +182,7 @@ abstract class ElectrumWalletBase
|
|||
SyncStatus syncStatus;
|
||||
|
||||
Set<String> get addressesSet => walletAddresses.allAddresses
|
||||
.where((element) => element.type != SegwitAddresType.mweb)
|
||||
.where((element) => element.type != SegwitAddressType.mweb)
|
||||
.map((addr) => addr.address)
|
||||
.toSet();
|
||||
|
||||
|
@ -439,7 +439,6 @@ abstract class ElectrumWalletBase
|
|||
BigintUtils.fromBytes(BytesUtils.fromHexString(unspent.silentPaymentLabel!)),
|
||||
)
|
||||
: silentAddress.B_spend,
|
||||
network: network,
|
||||
);
|
||||
|
||||
final addressRecord = walletAddresses.silentAddresses
|
||||
|
@ -624,9 +623,9 @@ abstract class ElectrumWalletBase
|
|||
|
||||
switch (coinTypeToSpendFrom) {
|
||||
case UnspentCoinType.mweb:
|
||||
return utx.bitcoinAddressRecord.type == SegwitAddresType.mweb;
|
||||
return utx.bitcoinAddressRecord.type == SegwitAddressType.mweb;
|
||||
case UnspentCoinType.nonMweb:
|
||||
return utx.bitcoinAddressRecord.type != SegwitAddresType.mweb;
|
||||
return utx.bitcoinAddressRecord.type != SegwitAddressType.mweb;
|
||||
case UnspentCoinType.any:
|
||||
return true;
|
||||
}
|
||||
|
@ -634,7 +633,7 @@ abstract class ElectrumWalletBase
|
|||
final unconfirmedCoins = availableInputs.where((utx) => utx.confirmations == 0).toList();
|
||||
|
||||
// sort the unconfirmed coins so that mweb coins are last:
|
||||
availableInputs.sort((a, b) => a.bitcoinAddressRecord.type == SegwitAddresType.mweb ? 1 : -1);
|
||||
availableInputs.sort((a, b) => a.bitcoinAddressRecord.type == SegwitAddressType.mweb ? 1 : -1);
|
||||
|
||||
for (int i = 0; i < availableInputs.length; i++) {
|
||||
final utx = availableInputs[i];
|
||||
|
@ -642,7 +641,7 @@ abstract class ElectrumWalletBase
|
|||
|
||||
if (paysToSilentPayment) {
|
||||
// Check inputs for shared secret derivation
|
||||
if (utx.bitcoinAddressRecord.type == SegwitAddresType.p2wsh) {
|
||||
if (utx.bitcoinAddressRecord.type == SegwitAddressType.p2wsh) {
|
||||
throw BitcoinTransactionSilentPaymentsNotSupported();
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +676,7 @@ abstract class ElectrumWalletBase
|
|||
if (privkey != null) {
|
||||
inputPrivKeyInfos.add(ECPrivateInfo(
|
||||
privkey,
|
||||
address.type == SegwitAddresType.p2tr,
|
||||
address.type == SegwitAddressType.p2tr,
|
||||
tweak: !isSilentPayment,
|
||||
));
|
||||
|
||||
|
@ -1163,7 +1162,7 @@ abstract class ElectrumWalletBase
|
|||
throw Exception(error);
|
||||
}
|
||||
|
||||
if (utxo.utxo.isP2tr()) {
|
||||
if (utxo.utxo.isP2tr) {
|
||||
hasTaprootInputs = true;
|
||||
return key.privkey.signTapRoot(
|
||||
txDigest,
|
||||
|
@ -1230,7 +1229,7 @@ abstract class ElectrumWalletBase
|
|||
'change_address_index': walletAddresses.currentChangeAddressIndexByType,
|
||||
'addresses': walletAddresses.allAddresses.map((addr) => addr.toJSON()).toList(),
|
||||
'address_page_type': walletInfo.addressPageType == null
|
||||
? SegwitAddresType.p2wpkh.toString()
|
||||
? SegwitAddressType.p2wpkh.toString()
|
||||
: walletInfo.addressPageType.toString(),
|
||||
'balance': balance[currency]?.toJSON(),
|
||||
'derivationTypeIndex': walletInfo.derivationInfo?.derivationType?.index,
|
||||
|
@ -1370,7 +1369,7 @@ abstract class ElectrumWalletBase
|
|||
List<BitcoinUnspent> updatedUnspentCoins = [];
|
||||
|
||||
final previousUnspentCoins = List<BitcoinUnspent>.from(unspentCoins.where((utxo) =>
|
||||
utxo.bitcoinAddressRecord.type != SegwitAddresType.mweb &&
|
||||
utxo.bitcoinAddressRecord.type != SegwitAddressType.mweb &&
|
||||
utxo.bitcoinAddressRecord is! BitcoinSilentPaymentAddressRecord));
|
||||
|
||||
if (hasSilentPaymentsScanning) {
|
||||
|
@ -1384,13 +1383,13 @@ abstract class ElectrumWalletBase
|
|||
|
||||
// Set the balance of all non-silent payment and non-mweb addresses to 0 before updating
|
||||
walletAddresses.allAddresses
|
||||
.where((element) => element.type != SegwitAddresType.mweb)
|
||||
.where((element) => element.type != SegwitAddressType.mweb)
|
||||
.forEach((addr) {
|
||||
if (addr is! BitcoinSilentPaymentAddressRecord) addr.balance = 0;
|
||||
});
|
||||
|
||||
final addressFutures = walletAddresses.allAddresses
|
||||
.where((element) => element.type != SegwitAddresType.mweb)
|
||||
.where((element) => element.type != SegwitAddressType.mweb)
|
||||
.map((address) => fetchUnspent(address))
|
||||
.toList();
|
||||
|
||||
|
@ -1831,7 +1830,7 @@ abstract class ElectrumWalletBase
|
|||
throw Exception("Cannot find private key");
|
||||
}
|
||||
|
||||
if (utxo.utxo.isP2tr()) {
|
||||
if (utxo.utxo.isP2tr) {
|
||||
return key.signTapRoot(txDigest, sighash: sighash);
|
||||
} else {
|
||||
return key.signInput(txDigest, sigHash: sighash);
|
||||
|
@ -1978,7 +1977,7 @@ abstract class ElectrumWalletBase
|
|||
.map((type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
|
||||
} else if (type == WalletType.litecoin) {
|
||||
await Future.wait(LITECOIN_ADDRESS_TYPES
|
||||
.where((type) => type != SegwitAddresType.mweb)
|
||||
.where((type) => type != SegwitAddressType.mweb)
|
||||
.map((type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
|
||||
}
|
||||
|
||||
|
@ -2167,7 +2166,7 @@ abstract class ElectrumWalletBase
|
|||
final unsubscribedScriptHashes = walletAddresses.allAddresses.where(
|
||||
(address) =>
|
||||
!_scripthashesUpdateSubject.containsKey(address.getScriptHash(network)) &&
|
||||
address.type != SegwitAddresType.mweb,
|
||||
address.type != SegwitAddressType.mweb,
|
||||
);
|
||||
|
||||
await Future.wait(unsubscribedScriptHashes.map((address) async {
|
||||
|
@ -2707,7 +2706,7 @@ Future<void> startRefresh(ScanData scanData) async {
|
|||
isUsed: true,
|
||||
network: scanData.network,
|
||||
silentPaymentTweak: t_k,
|
||||
type: SegwitAddresType.p2tr,
|
||||
type: SegwitAddressType.p2tr,
|
||||
txCount: 1,
|
||||
balance: amount!,
|
||||
);
|
||||
|
@ -2800,15 +2799,15 @@ BitcoinAddressType _getScriptType(BitcoinBaseAddress type) {
|
|||
} else if (type is P2shAddress) {
|
||||
return P2shAddressType.p2wpkhInP2sh;
|
||||
} else if (type is P2wshAddress) {
|
||||
return SegwitAddresType.p2wsh;
|
||||
return SegwitAddressType.p2wsh;
|
||||
} else if (type is P2trAddress) {
|
||||
return SegwitAddresType.p2tr;
|
||||
return SegwitAddressType.p2tr;
|
||||
} else if (type is MwebAddress) {
|
||||
return SegwitAddresType.mweb;
|
||||
return SegwitAddressType.mweb;
|
||||
} else if (type is SilentPaymentsAddresType) {
|
||||
return SilentPaymentsAddresType.p2sp;
|
||||
} else {
|
||||
return SegwitAddresType.p2wpkh;
|
||||
return SegwitAddressType.p2wpkh;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,16 +17,16 @@ part 'electrum_wallet_addresses.g.dart';
|
|||
class ElectrumWalletAddresses = ElectrumWalletAddressesBase with _$ElectrumWalletAddresses;
|
||||
|
||||
const List<BitcoinAddressType> BITCOIN_ADDRESS_TYPES = [
|
||||
SegwitAddresType.p2wpkh,
|
||||
SegwitAddressType.p2wpkh,
|
||||
P2pkhAddressType.p2pkh,
|
||||
SegwitAddresType.p2tr,
|
||||
SegwitAddresType.p2wsh,
|
||||
SegwitAddressType.p2tr,
|
||||
SegwitAddressType.p2wsh,
|
||||
P2shAddressType.p2wpkhInP2sh,
|
||||
];
|
||||
|
||||
const List<BitcoinAddressType> LITECOIN_ADDRESS_TYPES = [
|
||||
SegwitAddresType.p2wpkh,
|
||||
SegwitAddresType.mweb,
|
||||
SegwitAddressType.p2wpkh,
|
||||
SegwitAddressType.mweb,
|
||||
];
|
||||
|
||||
const List<BitcoinAddressType> BITCOIN_CASH_ADDRESS_TYPES = [
|
||||
|
@ -62,7 +62,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
_addressPageType = initialAddressPageType ??
|
||||
(walletInfo.addressPageType != null
|
||||
? BitcoinAddressType.fromValue(walletInfo.addressPageType!)
|
||||
: SegwitAddresType.p2wpkh),
|
||||
: SegwitAddressType.p2wpkh),
|
||||
silentAddresses = ObservableList<BitcoinSilentPaymentAddressRecord>.of(
|
||||
(initialSilentAddresses ?? []).toSet()),
|
||||
currentSilentAddressIndex = initialSilentAddressIndex,
|
||||
|
@ -249,17 +249,17 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
if (walletInfo.type == WalletType.bitcoinCash) {
|
||||
await _generateInitialAddresses(type: P2pkhAddressType.p2pkh);
|
||||
} else if (walletInfo.type == WalletType.litecoin) {
|
||||
await _generateInitialAddresses(type: SegwitAddresType.p2wpkh);
|
||||
await _generateInitialAddresses(type: SegwitAddressType.p2wpkh);
|
||||
if ((Platform.isAndroid || Platform.isIOS) && !isHardwareWallet) {
|
||||
await _generateInitialAddresses(type: SegwitAddresType.mweb);
|
||||
await _generateInitialAddresses(type: SegwitAddressType.mweb);
|
||||
}
|
||||
} else if (walletInfo.type == WalletType.bitcoin) {
|
||||
await _generateInitialAddresses();
|
||||
if (!isHardwareWallet) {
|
||||
await _generateInitialAddresses(type: P2pkhAddressType.p2pkh);
|
||||
await _generateInitialAddresses(type: P2shAddressType.p2wpkhInP2sh);
|
||||
await _generateInitialAddresses(type: SegwitAddresType.p2tr);
|
||||
await _generateInitialAddresses(type: SegwitAddresType.p2wsh);
|
||||
await _generateInitialAddresses(type: SegwitAddressType.p2tr);
|
||||
await _generateInitialAddresses(type: SegwitAddressType.p2wsh);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
BaseBitcoinAddressRecord generateNewAddress({String label = ''}) {
|
||||
if (addressPageType == SilentPaymentsAddresType.p2sp && silentAddress != null) {
|
||||
final currentSilentAddressIndex = silentAddresses
|
||||
.where((addressRecord) => addressRecord.type != SegwitAddresType.p2tr)
|
||||
.where((addressRecord) => addressRecord.type != SegwitAddressType.p2tr)
|
||||
.length -
|
||||
1;
|
||||
|
||||
|
@ -381,7 +381,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
void addBitcoinAddressTypes() {
|
||||
final lastP2wpkh = _addresses
|
||||
.where((addressRecord) =>
|
||||
_isUnusedReceiveAddressByType(addressRecord, SegwitAddresType.p2wpkh))
|
||||
_isUnusedReceiveAddressByType(addressRecord, SegwitAddressType.p2wpkh))
|
||||
.toList()
|
||||
.last;
|
||||
if (lastP2wpkh.address != address) {
|
||||
|
@ -407,7 +407,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
}
|
||||
|
||||
final lastP2tr = _addresses.firstWhere(
|
||||
(addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddresType.p2tr));
|
||||
(addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddressType.p2tr));
|
||||
if (lastP2tr.address != address) {
|
||||
addressesMap[lastP2tr.address] = 'P2TR';
|
||||
} else {
|
||||
|
@ -415,7 +415,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
}
|
||||
|
||||
final lastP2wsh = _addresses.firstWhere(
|
||||
(addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddresType.p2wsh));
|
||||
(addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddressType.p2wsh));
|
||||
if (lastP2wsh.address != address) {
|
||||
addressesMap[lastP2wsh.address] = 'P2WSH';
|
||||
} else {
|
||||
|
@ -440,7 +440,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
void addLitecoinAddressTypes() {
|
||||
final lastP2wpkh = _addresses
|
||||
.where((addressRecord) =>
|
||||
_isUnusedReceiveAddressByType(addressRecord, SegwitAddresType.p2wpkh))
|
||||
_isUnusedReceiveAddressByType(addressRecord, SegwitAddressType.p2wpkh))
|
||||
.toList()
|
||||
.last;
|
||||
if (lastP2wpkh.address != address) {
|
||||
|
@ -450,7 +450,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
}
|
||||
|
||||
final lastMweb = _addresses.firstWhere(
|
||||
(addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddresType.mweb));
|
||||
(addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddressType.mweb));
|
||||
if (lastMweb.address != address) {
|
||||
addressesMap[lastMweb.address] = 'MWEB';
|
||||
} else {
|
||||
|
@ -560,14 +560,14 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
addressRecord.isHidden &&
|
||||
!addressRecord.isUsed &&
|
||||
// TODO: feature to change change address type. For now fixed to p2wpkh, the cheapest type
|
||||
(walletInfo.type != WalletType.bitcoin || addressRecord.type == SegwitAddresType.p2wpkh));
|
||||
(walletInfo.type != WalletType.bitcoin || addressRecord.type == SegwitAddressType.p2wpkh));
|
||||
changeAddresses.addAll(newAddresses);
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> discoverAddresses(List<BitcoinAddressRecord> addressList, bool isHidden,
|
||||
Future<String?> Function(BitcoinAddressRecord) getAddressHistory,
|
||||
{BitcoinAddressType type = SegwitAddresType.p2wpkh}) async {
|
||||
{BitcoinAddressType type = SegwitAddressType.p2wpkh}) async {
|
||||
final newAddresses = await _createNewAddresses(gap,
|
||||
startIndex: addressList.length, isHidden: isHidden, type: type);
|
||||
addAddresses(newAddresses);
|
||||
|
@ -581,7 +581,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
}
|
||||
|
||||
Future<void> _generateInitialAddresses(
|
||||
{BitcoinAddressType type = SegwitAddresType.p2wpkh}) async {
|
||||
{BitcoinAddressType type = SegwitAddressType.p2wpkh}) async {
|
||||
var countOfReceiveAddresses = 0;
|
||||
var countOfHiddenAddresses = 0;
|
||||
|
||||
|
@ -658,7 +658,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
|
||||
void _validateAddresses() {
|
||||
_addresses.forEach((element) async {
|
||||
if (element.type == SegwitAddresType.mweb) {
|
||||
if (element.type == SegwitAddressType.mweb) {
|
||||
// this would add a ton of startup lag for mweb addresses since we have 1000 of them
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -87,8 +87,8 @@ class ElectrumWalletSnapshot {
|
|||
|
||||
final balance = ElectrumBalance.fromJSON(data['balance'] as String?) ??
|
||||
ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
||||
var regularAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
|
||||
var changeAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
|
||||
var regularAddressIndexByType = {SegwitAddressType.p2wpkh.toString(): 0};
|
||||
var changeAddressIndexByType = {SegwitAddressType.p2wpkh.toString(): 0};
|
||||
var silentAddressIndex = 0;
|
||||
|
||||
final derivationType = DerivationType
|
||||
|
@ -97,10 +97,10 @@ class ElectrumWalletSnapshot {
|
|||
|
||||
try {
|
||||
regularAddressIndexByType = {
|
||||
SegwitAddresType.p2wpkh.toString(): int.parse(data['account_index'] as String? ?? '0')
|
||||
SegwitAddressType.p2wpkh.toString(): int.parse(data['account_index'] as String? ?? '0')
|
||||
};
|
||||
changeAddressIndexByType = {
|
||||
SegwitAddresType.p2wpkh.toString():
|
||||
SegwitAddressType.p2wpkh.toString():
|
||||
int.parse(data['change_address_index'] as String? ?? '0')
|
||||
};
|
||||
silentAddressIndex = int.parse(data['silent_address_index'] as String? ?? '0');
|
||||
|
|
|
@ -50,7 +50,7 @@ import 'package:ledger_litecoin/ledger_litecoin.dart';
|
|||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_mweb/cw_mweb.dart';
|
||||
import 'package:bitcoin_base/src/crypto/keypair/sign_utils.dart';
|
||||
// import 'package:bitcoin_base/src/crypto/keypair/sign_utils.dart';
|
||||
import 'package:pointycastle/ecc/api.dart';
|
||||
import 'package:pointycastle/ecc/curves/secp256k1.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -690,16 +690,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
throw Exception(error);
|
||||
}
|
||||
|
||||
if (utxo.utxo.isP2tr()) {
|
||||
hasTaprootInputs = true;
|
||||
return key.privkey.signTapRoot(
|
||||
txDigest,
|
||||
sighash: sighash,
|
||||
tweak: utxo.utxo.isSilentPayment != true,
|
||||
);
|
||||
} else {
|
||||
return key.privkey.signInput(txDigest, sigHash: sighash);
|
||||
}
|
||||
return key.privkey.signInput(txDigest, sigHash: sighash);
|
||||
});
|
||||
|
||||
return PendingBitcoinTransaction(transaction, type,
|
||||
|
|
|
@ -51,7 +51,7 @@ extension PsbtSigner on PsbtV2 {
|
|||
List<BigInt> taprootAmounts = [];
|
||||
List<Script> taprootScripts = [];
|
||||
|
||||
if (utxos.any((e) => e.utxo.isP2tr())) {
|
||||
if (utxos.any((e) => e.utxo.isP2tr)) {
|
||||
for (final input in tx.inputs) {
|
||||
final utxo = utxos.firstWhereOrNull(
|
||||
(u) => u.utxo.txHash == input.txId && u.utxo.vout == input.txIndex);
|
||||
|
@ -76,7 +76,7 @@ extension PsbtSigner on PsbtV2 {
|
|||
/// We receive the owner's ScriptPubKey
|
||||
final script = _findLockingScript(utxo, false);
|
||||
|
||||
final int sighash = utxo.utxo.isP2tr()
|
||||
final int sighash = utxo.utxo.isP2tr
|
||||
? BitcoinOpCodeConst.TAPROOT_SIGHASH_ALL
|
||||
: BitcoinOpCodeConst.SIGHASH_ALL;
|
||||
|
||||
|
@ -87,7 +87,7 @@ extension PsbtSigner on PsbtV2 {
|
|||
/// now we need sign the transaction digest
|
||||
final sig = signer(digest, utxo, utxo.privateKey, sighash);
|
||||
|
||||
if (utxo.utxo.isP2tr()) {
|
||||
if (utxo.utxo.isP2tr) {
|
||||
setInputTapKeySig(i, Uint8List.fromList(BytesUtils.fromHexString(sig)));
|
||||
} else {
|
||||
setInputPartialSig(
|
||||
|
@ -106,7 +106,7 @@ extension PsbtSigner on PsbtV2 {
|
|||
List<BigInt> taprootAmounts,
|
||||
List<Script> tapRootPubKeys) {
|
||||
if (utxo.isSegwit()) {
|
||||
if (utxo.isP2tr()) {
|
||||
if (utxo.isP2tr) {
|
||||
return transaction.getTransactionTaprootDigset(
|
||||
txIndex: input,
|
||||
scriptPubKeys: tapRootPubKeys,
|
||||
|
@ -129,23 +129,23 @@ extension PsbtSigner on PsbtV2 {
|
|||
switch (utxo.utxo.scriptType) {
|
||||
case PubKeyAddressType.p2pk:
|
||||
return senderPub.toRedeemScript();
|
||||
case SegwitAddresType.p2wsh:
|
||||
case SegwitAddressType.p2wsh:
|
||||
if (isTaproot) {
|
||||
return senderPub.toP2wshAddress().toScriptPubKey();
|
||||
}
|
||||
return senderPub.toP2wshRedeemScript();
|
||||
case P2pkhAddressType.p2pkh:
|
||||
return senderPub.toP2pkhAddress().toScriptPubKey();
|
||||
case SegwitAddresType.p2wpkh:
|
||||
case SegwitAddressType.p2wpkh:
|
||||
if (isTaproot) {
|
||||
return senderPub.toP2wpkhAddress().toScriptPubKey();
|
||||
}
|
||||
return senderPub.toP2pkhAddress().toScriptPubKey();
|
||||
case SegwitAddresType.p2tr:
|
||||
case SegwitAddressType.p2tr:
|
||||
return senderPub
|
||||
.toTaprootAddress(tweak: utxo.utxo.isSilentPayment != true)
|
||||
.toScriptPubKey();
|
||||
case SegwitAddresType.mweb:
|
||||
case SegwitAddressType.mweb:
|
||||
return Script(script: []);
|
||||
case P2shAddressType.p2pkhInP2sh:
|
||||
if (isTaproot) {
|
||||
|
|
|
@ -17,7 +17,7 @@ class PSBTTransactionBuild {
|
|||
for (var i = 0; i < inputs.length; i++) {
|
||||
final input = inputs[i];
|
||||
|
||||
printV(input.utxo.isP2tr());
|
||||
printV(input.utxo.isP2tr);
|
||||
printV(input.utxo.isSegwit());
|
||||
printV(input.utxo.isP2shSegwit());
|
||||
|
||||
|
@ -30,7 +30,7 @@ class PSBTTransactionBuild {
|
|||
setInputSegwit(i, input);
|
||||
} else if (input.utxo.isP2shSegwit()) {
|
||||
setInputP2shSegwit(i, input);
|
||||
} else if (input.utxo.isP2tr()) {
|
||||
} else if (input.utxo.isP2tr) {
|
||||
// ToDo: (Konsti) Handle Taproot Inputs
|
||||
} else {
|
||||
setInputP2pkh(i, input);
|
||||
|
|
|
@ -81,20 +81,20 @@ packages:
|
|||
source: git
|
||||
version: "1.0.1"
|
||||
bitcoin_base:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
path: "."
|
||||
ref: cake-update-v7
|
||||
resolved-ref: f577e83fe78766b2655ea0602baa9299b953a31b
|
||||
ref: "2ab3437bd5a671e3f5833e5613eb98751e108bb7"
|
||||
resolved-ref: "2ab3437bd5a671e3f5833e5613eb98751e108bb7"
|
||||
url: "https://github.com/cake-tech/bitcoin_base"
|
||||
source: git
|
||||
version: "4.7.0"
|
||||
version: "6.1.0"
|
||||
bitcoin_base_old:
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
path: "."
|
||||
ref: cake-update-old
|
||||
resolved-ref: f39aa0b62642eaf1e9de5b31e2395148e73c7fd2
|
||||
ref: cd98de1d47895085e58fc8433b4ce41a157fc342
|
||||
resolved-ref: cd98de1d47895085e58fc8433b4ce41a157fc342
|
||||
url: "https://github.com/cake-tech/bitcoin_base"
|
||||
source: git
|
||||
version: "4.7.0"
|
||||
|
@ -107,6 +107,15 @@ packages:
|
|||
url: "https://github.com/cake-tech/blockchain_utils"
|
||||
source: git
|
||||
version: "3.3.0"
|
||||
blockchain_utils_new:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: cake-update-v4-renamed
|
||||
resolved-ref: "8fdcf98f0ce8842517e33be7643dc45ffd18e455"
|
||||
url: "https://github.com/cake-tech/blockchain_utils"
|
||||
source: git
|
||||
version: "4.3.0"
|
||||
bluez:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -73,7 +73,11 @@ dependency_overrides:
|
|||
bitcoin_base_old:
|
||||
git:
|
||||
url: https://github.com/cake-tech/bitcoin_base
|
||||
ref: cake-update-old
|
||||
ref: cd98de1d47895085e58fc8433b4ce41a157fc342
|
||||
bitcoin_base:
|
||||
git:
|
||||
url: https://github.com/cake-tech/bitcoin_base
|
||||
ref: 2ab3437bd5a671e3f5833e5613eb98751e108bb7
|
||||
pointycastle: 3.7.4
|
||||
ffi: 2.1.0
|
||||
|
||||
|
|
|
@ -39,10 +39,10 @@ dev_dependencies:
|
|||
|
||||
dependency_overrides:
|
||||
watcher: ^1.1.0
|
||||
bitcoin_base_old:
|
||||
bitcoin_base:
|
||||
git:
|
||||
url: https://github.com/cake-tech/bitcoin_base
|
||||
ref: cake-update-old
|
||||
ref: cake-update-v9
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -161,10 +161,10 @@ dependency_overrides:
|
|||
ref: cake
|
||||
flutter_secure_storage_platform_interface: 1.0.2
|
||||
protobuf: ^3.1.0
|
||||
bitcoin_base_old:
|
||||
bitcoin_base:
|
||||
git:
|
||||
url: https://github.com/cake-tech/bitcoin_base
|
||||
ref: cake-update-old
|
||||
ref: cake-update-v9
|
||||
ffi: 2.1.0
|
||||
ledger_flutter_plus:
|
||||
git:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue