mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 19:02:01 +01:00
* GreenField: Wallet API
* more work
* wip
* rough fiunish of transaction sending api
* Allow to create tx without broadcasting and small fixes
* Refactor Wallet Receive feature ad add greenfield api for address reserve for wallet
* add wallet api client
* add docs
* fix json converter tags
* fixes and add wallet tests
* fix tests
* fix rebase
* fixes
* just pass the tests already
* ugggh
* small cleanup
* revert int support in numeric string converter and make block id as native number in json
* fix LN endpoint
* try fix flaky test
* Revert "try fix flaky test"
This reverts commit 2e0d256325
.
* try fix other flaky test
* return proepr error if fee rate could not be fetched
* try fix test again
* reduce fee related logic for wallet api
* try reduce code changes for pr scope
* change auth logic for initial release of wallet api
46 lines
1.8 KiB
C#
46 lines
1.8 KiB
C#
#if ALTCOINS
|
|
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 List<TransactionInformation> FilterValidTransactions(List<TransactionInformation> transactionInformationSet)
|
|
{
|
|
return transactionInformationSet.FindAll(information =>
|
|
information.Outputs.Any(output =>
|
|
output.Value is AssetMoney assetMoney && assetMoney.AssetId == AssetId) ||
|
|
information.Inputs.Any(output =>
|
|
output.Value is AssetMoney assetMoney && assetMoney.AssetId == AssetId));
|
|
}
|
|
|
|
public override string GenerateBIP21(string cryptoInfoAddress, Money cryptoInfoDue)
|
|
{
|
|
//precision 0: 10 = 0.00000010
|
|
//precision 2: 10 = 0.00001000
|
|
//precision 8: 10 = 10
|
|
var money = new Money(cryptoInfoDue.ToDecimal(MoneyUnit.BTC) / decimal.Parse("1".PadRight(1 + 8 - Divisibility, '0')), MoneyUnit.BTC);
|
|
return $"{base.GenerateBIP21(cryptoInfoAddress, money)}&assetid={AssetId}";
|
|
}
|
|
}
|
|
}
|
|
#endif
|