Skip to content

Commit

Permalink
Rely on PSBT for signing
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Sep 5, 2024
1 parent 18e92e7 commit 8d29ad1
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 355 deletions.
164 changes: 77 additions & 87 deletions NBitcoin.Tests/BIP322Tests.cs

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions NBitcoin/BIP322/BIP322Signature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@

namespace NBitcoin.BIP322
{
public enum SignatureType
{
Legacy,
Simple,
Full
}

public enum HashType
{
Legacy,
BIP322
}
public abstract class BIP322Signature
{
public Network Network { get; }
Expand Down Expand Up @@ -132,11 +144,16 @@ public Full(Transaction signedTransaction, Network network) : base(network)
if (!IsValid(signedTransaction))
throw new ArgumentException("This isn't a valid BIP0322 to_sign transaction", nameof(signedTransaction));
SignedTransaction = signedTransaction;
FundProofs = signedTransaction.Inputs.Skip(1).ToArray();
}

public TxIn[] FundProofs { get; }

public Transaction SignedTransaction { get; }
static Script OpReturn = new Script("OP_RETURN");
internal static bool IsValid(Transaction tx) =>
tx.Outputs.Count == 1 &&
tx.Inputs.Count > 0 &&
tx.Inputs[0].Sequence == 0 &&
tx.Outputs[0].Value == Money.Zero &&
tx.Outputs[0].ScriptPubKey == OpReturn;
Expand Down
266 changes: 0 additions & 266 deletions NBitcoin/BIP322o.cs

This file was deleted.

2 changes: 1 addition & 1 deletion NBitcoin/BitcoinAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override Script GeneratePaymentScript()
/// <summary>
/// Base58 representation of a bitcoin address
/// </summary>
public abstract class BitcoinAddress : IDestination, IBitcoinString
public abstract partial class BitcoinAddress : IDestination, IBitcoinString
{
/// <summary>
/// Detect whether the input base58 is a pubkey hash or a script hash
Expand Down
Loading

0 comments on commit 8d29ad1

Please sign in to comment.