public IPayoutProof ParseProof(PayoutData payout)
    {
        if (payout?.Proof is null)
        {
            return(null);
        }
        var paymentMethodId = payout.GetPaymentMethodId();

        if (paymentMethodId is null)
        {
            return(null);
        }
        var raw = JObject.Parse(Encoding.UTF8.GetString(payout.Proof));

        if (raw.TryGetValue("proofType", StringComparison.InvariantCultureIgnoreCase, out var proofType) &&
            proofType.Value <string>() == ManualPayoutProof.Type)
        {
            return(raw.ToObject <ManualPayoutProof>());
        }
        var res = raw.ToObject <PayoutTransactionOnChainBlob>(
            JsonSerializer.Create(_jsonSerializerSettings.GetSerializer(paymentMethodId.CryptoCode)));
        var network = _btcPayNetworkProvider.GetNetwork <BTCPayNetwork>(paymentMethodId.CryptoCode);

        if (res == null)
        {
            return(null);
        }
        res.LinkTemplate = network.BlockExplorerLink;
        return(res);
    }
Exemplo n.º 2
0
    public IPayoutProof ParseProof(PayoutData payout)
    {
        if (payout?.Proof is null)
        {
            return(null);
        }
        var paymentMethodId = payout.GetPaymentMethodId();
        var res             = JsonConvert.DeserializeObject <PayoutTransactionOnChainBlob>(Encoding.UTF8.GetString(payout.Proof), _jsonSerializerSettings.GetSerializer(paymentMethodId.CryptoCode));
        var network         = _btcPayNetworkProvider.GetNetwork <BTCPayNetwork>(paymentMethodId.CryptoCode);

        res.LinkTemplate = network.BlockExplorerLink;
        return(res);
    }
Exemplo n.º 3
0
 public static void SetBlob(this PayoutData data, PayoutBlob blob, BTCPayNetworkJsonSerializerSettings serializers)
 {
     data.Blob = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(blob, serializers.GetSerializer(data.GetPaymentMethodId().CryptoCode)));
 }
Exemplo n.º 4
0
 public static PayoutBlob GetBlob(this PayoutData data, BTCPayNetworkJsonSerializerSettings serializers)
 {
     return(JsonConvert.DeserializeObject <PayoutBlob>(Encoding.UTF8.GetString(data.Blob), serializers.GetSerializer(data.GetPaymentMethodId().CryptoCode)));
 }
    public void SetProofBlob(PayoutData data, PayoutTransactionOnChainBlob blob)
    {
        var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(blob, _jsonSerializerSettings.GetSerializer(data.GetPaymentMethodId().CryptoCode)));

        // We only update the property if the bytes actually changed, this prevent from hammering the DB too much
        if (data.Proof is null || bytes.Length != data.Proof.Length || !bytes.SequenceEqual(data.Proof))
        {
            data.Proof = bytes;
        }
    }
Exemplo n.º 6
0
 public static PayoutTransactionOnChainBlob GetProofBlob(this PayoutData data, BTCPayNetworkJsonSerializerSettings serializers)
 {
     if (data.Proof is null)
     {
         return(null);
     }
     return(JsonConvert.DeserializeObject <PayoutTransactionOnChainBlob>(Encoding.UTF8.GetString(data.Proof), serializers.GetSerializer(data.GetPaymentMethodId().CryptoCode)));
 }
Exemplo n.º 7
0
 //we group per store and init the transfers by each
 async Task <bool> TrypayBolt(ILightningClient lightningClient, PayoutBlob payoutBlob, PayoutData payoutData,
                              BOLT11PaymentRequest bolt11PaymentRequest)
 {
     return((await UILightningLikePayoutController.TrypayBolt(lightningClient, payoutBlob, payoutData, bolt11PaymentRequest,
                                                              payoutData.GetPaymentMethodId())).Result == PayResult.Ok);
 }