mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-24 14:50:50 +01:00
The way liquid assets decimal precision works is just an ui layer. Each unit of an asset is actually 1sat. Fixes https://github.com/Blockstream/green_android/issues/86
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NBitcoin;
|
|
using NBXplorer;
|
|
using NBXplorer.Models;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
public class ElementsBTCPayNetwork : BTCPayNetwork
|
|
{
|
|
public string NetworkCryptoCode { get; set; }
|
|
public uint256 AssetId { get; set; }
|
|
public override bool ReadonlyWallet { get; set; } = true;
|
|
|
|
public override IEnumerable<(MatchedOutput matchedOutput, OutPoint outPoint)> GetValidOutputs(
|
|
NewTransactionEvent evtOutputs)
|
|
{
|
|
return evtOutputs.Outputs.Where(output =>
|
|
output.Value is AssetMoney assetMoney && assetMoney.AssetId == AssetId).Select(output =>
|
|
{
|
|
var outpoint = new OutPoint(evtOutputs.TransactionData.TransactionHash, output.Index);
|
|
return (output, outpoint);
|
|
});
|
|
}
|
|
|
|
public override string GenerateBIP21(string cryptoInfoAddress, Money cryptoInfoDue)
|
|
{
|
|
return $"{base.GenerateBIP21(cryptoInfoAddress, new Money(long.Parse(cryptoInfoDue.ToString(false, true).Replace(".", ""))))}&assetid={AssetId}";
|
|
}
|
|
}
|
|
}
|