mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
ensure only non segwit payment code is ever shown
This commit is contained in:
parent
8018a887cf
commit
289009be18
10 changed files with 33 additions and 34 deletions
|
@ -14,6 +14,9 @@ class PaynymAccount {
|
||||||
/// list of nymId
|
/// list of nymId
|
||||||
final List<PaynymAccountLite> following;
|
final List<PaynymAccountLite> following;
|
||||||
|
|
||||||
|
PaynymCode get nonSegwitPaymentCode =>
|
||||||
|
codes.firstWhere((element) => !element.segwit);
|
||||||
|
|
||||||
PaynymAccount(
|
PaynymAccount(
|
||||||
this.nymID,
|
this.nymID,
|
||||||
this.nymName,
|
this.nymName,
|
||||||
|
|
|
@ -447,7 +447,7 @@ class _AddNewPaynymFollowViewState
|
||||||
child: PaynymCard(
|
child: PaynymCard(
|
||||||
key: UniqueKey(),
|
key: UniqueKey(),
|
||||||
label: _searchResult!.nymName,
|
label: _searchResult!.nymName,
|
||||||
paymentCodeString: _searchResult!.codes.first.code,
|
paymentCodeString: _searchResult!.nonSegwitPaymentCode.code,
|
||||||
walletId: widget.walletId,
|
walletId: widget.walletId,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -55,7 +55,7 @@ class PaynymQrPopup extends StatelessWidget {
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
PayNymBot(
|
PayNymBot(
|
||||||
paymentCodeString: paynymAccount.codes.first.code,
|
paymentCodeString: paynymAccount.nonSegwitPaymentCode.code,
|
||||||
size: isDesktop ? 56 : 36,
|
size: isDesktop ? 56 : 36,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -108,7 +108,7 @@ class PaynymQrPopup extends StatelessWidget {
|
||||||
height: 6,
|
height: 6,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
paynymAccount.codes.first.code,
|
paynymAccount.nonSegwitPaymentCode.code,
|
||||||
style: isDesktop
|
style: isDesktop
|
||||||
? STextStyles.desktopTextSmall(context)
|
? STextStyles.desktopTextSmall(context)
|
||||||
: STextStyles.infoSmall(context).copyWith(
|
: STextStyles.infoSmall(context).copyWith(
|
||||||
|
@ -127,7 +127,7 @@ class PaynymQrPopup extends StatelessWidget {
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Clipboard.setData(
|
await Clipboard.setData(
|
||||||
ClipboardData(
|
ClipboardData(
|
||||||
text: paynymAccount.codes.first.code,
|
text: paynymAccount.nonSegwitPaymentCode.code,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -150,7 +150,7 @@ class PaynymQrPopup extends StatelessWidget {
|
||||||
QrImage(
|
QrImage(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
size: 130,
|
size: 130,
|
||||||
data: paynymAccount.codes.first.code,
|
data: paynymAccount.nonSegwitPaymentCode.code,
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
Theme.of(context).extension<StackColors>()!.textDark,
|
Theme.of(context).extension<StackColors>()!.textDark,
|
||||||
),
|
),
|
||||||
|
|
|
@ -43,8 +43,9 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
||||||
// get wallet to access paynym calls
|
// get wallet to access paynym calls
|
||||||
final wallet = manager.wallet as PaynymWalletInterface;
|
final wallet = manager.wallet as PaynymWalletInterface;
|
||||||
|
|
||||||
final token =
|
final token = await ref
|
||||||
await ref.read(paynymAPIProvider).token(myAccount.codes.first.code);
|
.read(paynymAPIProvider)
|
||||||
|
.token(myAccount.nonSegwitPaymentCode.code);
|
||||||
final signature = await wallet.signStringWithNotificationKey(token.value!);
|
final signature = await wallet.signStringWithNotificationKey(token.value!);
|
||||||
|
|
||||||
final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);
|
final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);
|
||||||
|
|
|
@ -275,8 +275,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
paymentCodeString: ref
|
paymentCodeString: ref
|
||||||
.watch(myPaynymAccountStateProvider.state)
|
.watch(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -298,8 +297,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
ref
|
ref
|
||||||
.watch(myPaynymAccountStateProvider.state)
|
.watch(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
12,
|
12,
|
||||||
5),
|
5),
|
||||||
|
@ -330,8 +328,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
text: ref
|
text: ref
|
||||||
.read(myPaynymAccountStateProvider.state)
|
.read(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -376,8 +373,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
ref
|
ref
|
||||||
.read(myPaynymAccountStateProvider.state)
|
.read(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
sharePositionOrigin: sharePositionOrigin);
|
sharePositionOrigin: sharePositionOrigin);
|
||||||
},
|
},
|
||||||
|
@ -447,8 +443,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
paymentCodeString: ref
|
paymentCodeString: ref
|
||||||
.watch(myPaynymAccountStateProvider.state)
|
.watch(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -473,8 +468,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
ref
|
ref
|
||||||
.watch(myPaynymAccountStateProvider.state)
|
.watch(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
12,
|
12,
|
||||||
5),
|
5),
|
||||||
|
@ -501,8 +495,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
text: ref
|
text: ref
|
||||||
.read(myPaynymAccountStateProvider.state)
|
.read(myPaynymAccountStateProvider.state)
|
||||||
.state!
|
.state!
|
||||||
.codes
|
.nonSegwitPaymentCode
|
||||||
.first
|
|
||||||
.code,
|
.code,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -458,6 +458,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
final feeRate = ref.read(feeRateTypeStateProvider);
|
final feeRate = ref.read(feeRateTypeStateProvider);
|
||||||
txDataFuture = wallet.preparePaymentCodeSend(
|
txDataFuture = wallet.preparePaymentCodeSend(
|
||||||
paymentCode: paymentCode,
|
paymentCode: paymentCode,
|
||||||
|
isSegwit: widget.accountLite!.segwit,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
args: {
|
args: {
|
||||||
"feeRate": feeRate,
|
"feeRate": feeRate,
|
||||||
|
|
|
@ -925,7 +925,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
||||||
|
|
||||||
// check if account exists and for matching code to see if claimed
|
// check if account exists and for matching code to see if claimed
|
||||||
if (account.value != null &&
|
if (account.value != null &&
|
||||||
account.value!.codes.first.claimed &&
|
account.value!.nonSegwitPaymentCode.claimed &&
|
||||||
account.value!.segwit) {
|
account.value!.segwit) {
|
||||||
ref.read(myPaynymAccountStateProvider.state).state =
|
ref.read(myPaynymAccountStateProvider.state).state =
|
||||||
account.value!;
|
account.value!;
|
||||||
|
|
|
@ -262,11 +262,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
final wallet = manager.wallet as PaynymWalletInterface;
|
final wallet = manager.wallet as PaynymWalletInterface;
|
||||||
final paymentCode = PaymentCode.fromPaymentCode(
|
final paymentCode = PaymentCode.fromPaymentCode(
|
||||||
widget.accountLite!.code,
|
widget.accountLite!.code,
|
||||||
wallet.networkType,
|
networkType: wallet.networkType,
|
||||||
);
|
);
|
||||||
final feeRate = ref.read(feeRateTypeStateProvider);
|
final feeRate = ref.read(feeRateTypeStateProvider);
|
||||||
txDataFuture = wallet.preparePaymentCodeSend(
|
txDataFuture = wallet.preparePaymentCodeSend(
|
||||||
paymentCode: paymentCode,
|
paymentCode: paymentCode,
|
||||||
|
isSegwit: widget.accountLite!.segwit,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
args: {
|
args: {
|
||||||
"feeRate": feeRate,
|
"feeRate": feeRate,
|
||||||
|
|
|
@ -284,7 +284,7 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
|
||||||
|
|
||||||
// check if account exists and for matching code to see if claimed
|
// check if account exists and for matching code to see if claimed
|
||||||
if (account.value != null &&
|
if (account.value != null &&
|
||||||
account.value!.codes.first.claimed &&
|
account.value!.nonSegwitPaymentCode.claimed &&
|
||||||
account.value!.segwit) {
|
account.value!.segwit) {
|
||||||
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ class _PaynymFollowToggleButtonState
|
||||||
// sign token with notification private key
|
// sign token with notification private key
|
||||||
String signature = await wallet.signStringWithNotificationKey(token.value!);
|
String signature = await wallet.signStringWithNotificationKey(token.value!);
|
||||||
|
|
||||||
var result = await ref.read(paynymAPIProvider).follow(
|
var result = await ref.read(paynymAPIProvider).follow(token.value!,
|
||||||
token.value!, signature, followedAccount.value!.codes.first.code);
|
signature, followedAccount.value!.nonSegwitPaymentCode.code);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (;
|
for (;
|
||||||
|
@ -88,8 +88,8 @@ class _PaynymFollowToggleButtonState
|
||||||
// sign token with notification private key
|
// sign token with notification private key
|
||||||
signature = await wallet.signStringWithNotificationKey(token.value!);
|
signature = await wallet.signStringWithNotificationKey(token.value!);
|
||||||
|
|
||||||
result = await ref.read(paynymAPIProvider).follow(
|
result = await ref.read(paynymAPIProvider).follow(token.value!, signature,
|
||||||
token.value!, signature, followedAccount.value!.codes.first.code);
|
followedAccount.value!.nonSegwitPaymentCode.code);
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
await Future<void>.delayed(const Duration(milliseconds: 200));
|
||||||
|
|
||||||
print("RRR result: $result");
|
print("RRR result: $result");
|
||||||
|
@ -116,8 +116,8 @@ class _PaynymFollowToggleButtonState
|
||||||
PaynymAccountLite(
|
PaynymAccountLite(
|
||||||
followedAccount.value!.nymID,
|
followedAccount.value!.nymID,
|
||||||
followedAccount.value!.nymName,
|
followedAccount.value!.nymName,
|
||||||
followedAccount.value!.codes.first.code,
|
followedAccount.value!.nonSegwitPaymentCode.code,
|
||||||
followedAccount.value!.codes.first.segwit,
|
followedAccount.value!.segwit,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -175,8 +175,8 @@ class _PaynymFollowToggleButtonState
|
||||||
// sign token with notification private key
|
// sign token with notification private key
|
||||||
String signature = await wallet.signStringWithNotificationKey(token.value!);
|
String signature = await wallet.signStringWithNotificationKey(token.value!);
|
||||||
|
|
||||||
var result = await ref.read(paynymAPIProvider).unfollow(
|
var result = await ref.read(paynymAPIProvider).unfollow(token.value!,
|
||||||
token.value!, signature, followedAccount.value!.codes.first.code);
|
signature, followedAccount.value!.nonSegwitPaymentCode.code);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (;
|
for (;
|
||||||
|
@ -188,8 +188,8 @@ class _PaynymFollowToggleButtonState
|
||||||
// sign token with notification private key
|
// sign token with notification private key
|
||||||
signature = await wallet.signStringWithNotificationKey(token.value!);
|
signature = await wallet.signStringWithNotificationKey(token.value!);
|
||||||
|
|
||||||
result = await ref.read(paynymAPIProvider).unfollow(
|
result = await ref.read(paynymAPIProvider).unfollow(token.value!,
|
||||||
token.value!, signature, followedAccount.value!.codes.first.code);
|
signature, followedAccount.value!.nonSegwitPaymentCode.code);
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
await Future<void>.delayed(const Duration(milliseconds: 200));
|
||||||
print("unfollow RRR result: $result");
|
print("unfollow RRR result: $result");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue