Skip to content

Commit

Permalink
Revert: Do not make PartialSigs in PSBT abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed May 20, 2024
1 parent a690b46 commit a61085a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
10 changes: 3 additions & 7 deletions NBitcoin/BIP174/PSBTInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Newtonsoft.Json;
using System.IO;
using NBitcoin.DataEncoders;
using PartialSigKVMap = System.Collections.Generic.SortedDictionary<NBitcoin.PubKey, NBitcoin.ITransactionSignature>;
using PartialSigKVMap = System.Collections.Generic.SortedDictionary<NBitcoin.PubKey, NBitcoin.TransactionSignature>;
using System.Diagnostics.CodeAnalysis;
using NBitcoin.Crypto;
using System.Text;
Expand Down Expand Up @@ -1094,12 +1094,8 @@ internal void Sign(KeyPair keyPair, SigningOptions? signingOptions)
#endif
CheckCompatibleSigHash(sigHash);
var signature = PartialSigs[ecdsapk];
#if HAS_SPAN
var existingSigHash = existingSig is TaprootSignature ts ? (uint)ts.SigHash :
(uint)((TransactionSignature)existingSig).SigHash;
#else
var existingSigHash = (uint)((TransactionSignature)existingSig).SigHash;
#endif

var existingSigHash = (uint)existingSig.SigHash;
if (Transaction is IHasForkId)
existingSigHash = existingSigHash & ~(0x40u);
if (!SameSigHash(existingSigHash, sigHash))
Expand Down
4 changes: 2 additions & 2 deletions NBitcoin/BuilderExtensions/P2MultiSigBuilderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override void Finalize(InputSigningContext inputSigningContext)
var multiSigParams = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(scriptPubKey)!;
if (multiSigParams.SignatureCount > txIn.PartialSigs.Count)
return;
List<ITransactionSignature> sigs = new List<ITransactionSignature>();
List<TransactionSignature> sigs = new List<TransactionSignature>();
int sigcount = 0;
foreach (var pk in multiSigParams.PubKeys)
{
Expand Down Expand Up @@ -185,7 +185,7 @@ public override void MergePartialSignatures(InputSigningContext inputSigningCont
var txIn = inputSigningContext.Input;
var scriptPubKey = inputSigningContext.Coin.GetScriptCode();

var sigs = new ITransactionSignature?[multiSigParams.PubKeys.Length];
var sigs = new TransactionSignature?[multiSigParams.PubKeys.Length];
int sigCount = 0;
for (int i = 0; i < multiSigParams.PubKeys.Length; i++)
{
Expand Down
10 changes: 5 additions & 5 deletions NBitcoin/StandardScriptTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps,
}
}

public Script GenerateScriptSig(ITransactionSignature[] signatures)
public Script GenerateScriptSig(TransactionSignature[] signatures)
{
return GenerateScriptSig((IEnumerable<ITransactionSignature>)signatures);
return GenerateScriptSig((IEnumerable<TransactionSignature>)signatures);
}

public Script GenerateScriptSig(IEnumerable<ITransactionSignature> signatures)
public Script GenerateScriptSig(IEnumerable<TransactionSignature> signatures)
{
List<Op> ops = new List<Op>();
ops.Add(OpcodeType.OP_0);
Expand Down Expand Up @@ -604,7 +604,7 @@ public Script GenerateScriptSig(ECDSASignature signature)
{
return GenerateScriptSig(new TransactionSignature(signature, SigHash.All));
}
public Script GenerateScriptSig(ITransactionSignature signature)
public Script GenerateScriptSig(TransactionSignature signature)
{
return new Script(
Op.GetPushOp(signature.ToBytes())
Expand Down Expand Up @@ -803,7 +803,7 @@ public Script GenerateScriptPubKey(KeyId pubkeyHash)
);
}

public Script GenerateScriptSig(ITransactionSignature? signature, PubKey publicKey)
public Script GenerateScriptSig(TransactionSignature? signature, PubKey publicKey)
{
if (publicKey == null)
throw new ArgumentNullException(nameof(publicKey));
Expand Down

0 comments on commit a61085a

Please sign in to comment.