Merge pull request #5234 from mempool/nymkappa/fix-bitcoin-rounding

[btcpay] fix displayed amount
This commit is contained in:
softsimon 2024-06-30 14:54:26 +09:00 committed by GitHub
commit 7caad9fca9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 10 deletions

View File

@ -33,8 +33,8 @@
<ng-template [ngIf]="paymentForm.get('method')?.value === 'chain' && invoice"> <ng-template [ngIf]="paymentForm.get('method')?.value === 'chain' && invoice">
<div class="qr-wrapper" [class.mt-0]="minimal"> <div class="qr-wrapper" [class.mt-0]="minimal">
<a [href]="bypassSecurityTrustUrl('bitcoin:' + invoice.addresses.BTC + '?amount=' + invoice.amount)" target="_blank"> <a [href]="bypassSecurityTrustUrl('bitcoin:' + invoice.addresses.BTC + '?amount=' + invoice.btcDue)" target="_blank">
<app-qrcode imageUrl="/resources/bitcoin-logo.png" [size]="200" [data]="'bitcoin:' + invoice.addresses.BTC + '?amount=' + invoice.amount"></app-qrcode> <app-qrcode imageUrl="/resources/bitcoin-logo.png" [size]="200" [data]="'bitcoin:' + invoice.addresses.BTC + '?amount=' + invoice.btcDue"></app-qrcode>
</a> </a>
</div> </div>
@ -45,7 +45,7 @@
</div> </div>
</div> </div>
@if (!minimal) { @if (!minimal) {
<p>{{ invoice.amount }} <span class="symbol">BTC</span></p> <p>{{ invoice.btcDue | number: '1.0-8' }} <span class="symbol">BTC</span></p>
} }
</ng-template> </ng-template>
@ -66,7 +66,7 @@
</div> </div>
@if (!minimal) { @if (!minimal) {
<p>{{ invoice.amount * 100_000_000 }} <span class="symbol">sats</span></p> <p>{{ invoice.btcDue * 100_000_000 | number: '1.0-0' }} <span class="symbol">sats</span></p>
} }
</ng-template> </ng-template>
@ -74,8 +74,8 @@
<ng-template [ngIf]="invoice && (paymentForm.get('method')?.value === 'lbtc' || paymentForm.get('method')?.value === 'tlbtc')"> <ng-template [ngIf]="invoice && (paymentForm.get('method')?.value === 'lbtc' || paymentForm.get('method')?.value === 'tlbtc')">
<div class="qr-wrapper" [class.mt-0]="minimal"> <div class="qr-wrapper" [class.mt-0]="minimal">
<a [href]="bypassSecurityTrustUrl('liquidnetwork:' + invoice.addresses.LBTC + '?amount=' + invoice.amount + '&assetid=6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d')" target="_blank"> <a [href]="bypassSecurityTrustUrl('liquidnetwork:' + invoice.addresses.LBTC + '?amount=' + invoice.btcDue + '&assetid=6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d')" target="_blank">
<app-qrcode imageUrl="/resources/liquid-bitcoin.png" [size]="200" [data]="'liquidnetwork:' + invoice.addresses.LBTC + '?amount=' + invoice.amount + '&assetid=6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d'"></app-qrcode> <app-qrcode imageUrl="/resources/liquid-bitcoin.png" [size]="200" [data]="'liquidnetwork:' + invoice.addresses.LBTC + '?amount=' + invoice.btcDue + '&assetid=6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d'"></app-qrcode>
</a> </a>
</div> </div>
<br> <br>
@ -86,7 +86,7 @@
</div> </div>
</div> </div>
@if (!minimal) { @if (!minimal) {
<p>{{ invoice.amount }} <span class="symbol">BTC</span></p> <p>{{ invoice.btcDue | number: '1.0-8' }} <span class="symbol">BTC</span></p>
} }
</ng-template> </ng-template>

View File

@ -65,9 +65,7 @@ export class BitcoinInvoiceComponent implements OnInit, OnDestroy {
this.paymentStatusSubscription = this.apiService.retreiveInvoice$(invoiceId).pipe( this.paymentStatusSubscription = this.apiService.retreiveInvoice$(invoiceId).pipe(
tap((invoice: any) => { tap((invoice: any) => {
this.invoice = invoice; this.invoice = invoice;
this.invoice.amount = invoice.btcDue ?? (invoice.cryptoInfo.length ? parseFloat(invoice.cryptoInfo[0].totalDue) : 0) ?? 0; if (this.invoice.btcDue > 0) {
if (this.invoice.amount > 0) {
this.paymentStatus = 2; this.paymentStatus = 2;
} else { } else {
this.paymentStatus = 4; this.paymentStatus = 4;