ensure only non segwit payment code is ever shown

This commit is contained in:
julian 2023-04-26 12:29:43 -06:00
parent 8018a887cf
commit 289009be18
10 changed files with 33 additions and 34 deletions

View file

@ -14,6 +14,9 @@ class PaynymAccount {
/// list of nymId
final List<PaynymAccountLite> following;
PaynymCode get nonSegwitPaymentCode =>
codes.firstWhere((element) => !element.segwit);
PaynymAccount(
this.nymID,
this.nymName,

View file

@ -447,7 +447,7 @@ class _AddNewPaynymFollowViewState
child: PaynymCard(
key: UniqueKey(),
label: _searchResult!.nymName,
paymentCodeString: _searchResult!.codes.first.code,
paymentCodeString: _searchResult!.nonSegwitPaymentCode.code,
walletId: widget.walletId,
),
),

View file

@ -55,7 +55,7 @@ class PaynymQrPopup extends StatelessWidget {
child: Row(
children: [
PayNymBot(
paymentCodeString: paynymAccount.codes.first.code,
paymentCodeString: paynymAccount.nonSegwitPaymentCode.code,
size: isDesktop ? 56 : 36,
),
const SizedBox(
@ -108,7 +108,7 @@ class PaynymQrPopup extends StatelessWidget {
height: 6,
),
Text(
paynymAccount.codes.first.code,
paynymAccount.nonSegwitPaymentCode.code,
style: isDesktop
? STextStyles.desktopTextSmall(context)
: STextStyles.infoSmall(context).copyWith(
@ -127,7 +127,7 @@ class PaynymQrPopup extends StatelessWidget {
onTap: () async {
await Clipboard.setData(
ClipboardData(
text: paynymAccount.codes.first.code,
text: paynymAccount.nonSegwitPaymentCode.code,
),
);
unawaited(
@ -150,7 +150,7 @@ class PaynymQrPopup extends StatelessWidget {
QrImage(
padding: const EdgeInsets.all(0),
size: 130,
data: paynymAccount.codes.first.code,
data: paynymAccount.nonSegwitPaymentCode.code,
foregroundColor:
Theme.of(context).extension<StackColors>()!.textDark,
),

View file

@ -43,8 +43,9 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
// get wallet to access paynym calls
final wallet = manager.wallet as PaynymWalletInterface;
final token =
await ref.read(paynymAPIProvider).token(myAccount.codes.first.code);
final token = await ref
.read(paynymAPIProvider)
.token(myAccount.nonSegwitPaymentCode.code);
final signature = await wallet.signStringWithNotificationKey(token.value!);
final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);

View file

@ -275,8 +275,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
paymentCodeString: ref
.watch(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
),
),
@ -298,8 +297,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
ref
.watch(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
12,
5),
@ -330,8 +328,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
text: ref
.read(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
),
);
@ -376,8 +373,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
ref
.read(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
sharePositionOrigin: sharePositionOrigin);
},
@ -447,8 +443,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
paymentCodeString: ref
.watch(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
),
),
@ -473,8 +468,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
ref
.watch(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
12,
5),
@ -501,8 +495,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
text: ref
.read(myPaynymAccountStateProvider.state)
.state!
.codes
.first
.nonSegwitPaymentCode
.code,
),
);

View file

@ -458,6 +458,7 @@ class _SendViewState extends ConsumerState<SendView> {
final feeRate = ref.read(feeRateTypeStateProvider);
txDataFuture = wallet.preparePaymentCodeSend(
paymentCode: paymentCode,
isSegwit: widget.accountLite!.segwit,
amount: amount,
args: {
"feeRate": feeRate,

View file

@ -925,7 +925,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
// check if account exists and for matching code to see if claimed
if (account.value != null &&
account.value!.codes.first.claimed &&
account.value!.nonSegwitPaymentCode.claimed &&
account.value!.segwit) {
ref.read(myPaynymAccountStateProvider.state).state =
account.value!;

View file

@ -262,11 +262,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final wallet = manager.wallet as PaynymWalletInterface;
final paymentCode = PaymentCode.fromPaymentCode(
widget.accountLite!.code,
wallet.networkType,
networkType: wallet.networkType,
);
final feeRate = ref.read(feeRateTypeStateProvider);
txDataFuture = wallet.preparePaymentCodeSend(
paymentCode: paymentCode,
isSegwit: widget.accountLite!.segwit,
amount: amount,
args: {
"feeRate": feeRate,

View file

@ -284,7 +284,7 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
// check if account exists and for matching code to see if claimed
if (account.value != null &&
account.value!.codes.first.claimed &&
account.value!.nonSegwitPaymentCode.claimed &&
account.value!.segwit) {
ref.read(myPaynymAccountStateProvider.state).state = account.value!;

View file

@ -75,8 +75,8 @@ class _PaynymFollowToggleButtonState
// sign token with notification private key
String signature = await wallet.signStringWithNotificationKey(token.value!);
var result = await ref.read(paynymAPIProvider).follow(
token.value!, signature, followedAccount.value!.codes.first.code);
var result = await ref.read(paynymAPIProvider).follow(token.value!,
signature, followedAccount.value!.nonSegwitPaymentCode.code);
int i = 0;
for (;
@ -88,8 +88,8 @@ class _PaynymFollowToggleButtonState
// sign token with notification private key
signature = await wallet.signStringWithNotificationKey(token.value!);
result = await ref.read(paynymAPIProvider).follow(
token.value!, signature, followedAccount.value!.codes.first.code);
result = await ref.read(paynymAPIProvider).follow(token.value!, signature,
followedAccount.value!.nonSegwitPaymentCode.code);
await Future<void>.delayed(const Duration(milliseconds: 200));
print("RRR result: $result");
@ -116,8 +116,8 @@ class _PaynymFollowToggleButtonState
PaynymAccountLite(
followedAccount.value!.nymID,
followedAccount.value!.nymName,
followedAccount.value!.codes.first.code,
followedAccount.value!.codes.first.segwit,
followedAccount.value!.nonSegwitPaymentCode.code,
followedAccount.value!.segwit,
),
);
@ -175,8 +175,8 @@ class _PaynymFollowToggleButtonState
// sign token with notification private key
String signature = await wallet.signStringWithNotificationKey(token.value!);
var result = await ref.read(paynymAPIProvider).unfollow(
token.value!, signature, followedAccount.value!.codes.first.code);
var result = await ref.read(paynymAPIProvider).unfollow(token.value!,
signature, followedAccount.value!.nonSegwitPaymentCode.code);
int i = 0;
for (;
@ -188,8 +188,8 @@ class _PaynymFollowToggleButtonState
// sign token with notification private key
signature = await wallet.signStringWithNotificationKey(token.value!);
result = await ref.read(paynymAPIProvider).unfollow(
token.value!, signature, followedAccount.value!.codes.first.code);
result = await ref.read(paynymAPIProvider).unfollow(token.value!,
signature, followedAccount.value!.nonSegwitPaymentCode.code);
await Future<void>.delayed(const Duration(milliseconds: 200));
print("unfollow RRR result: $result");
}