Skip to content

Commit 7026afd

Browse files
committed
Add more merged properties for PSBT2
1 parent 24d59cc commit 7026afd

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

NBitcoin/BIP174/PSBTInput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public void UpdateFromCoin(ICoin coin)
271271
/// Import informations contained by <paramref name="other"/> into this instance.
272272
/// </summary>
273273
/// <param name="other"></param>
274-
public void UpdateFrom(PSBTInput other)
274+
public virtual void UpdateFrom(PSBTInput other)
275275
{
276276
if (other == null)
277277
throw new ArgumentNullException(nameof(other));

NBitcoin/BIP174/PartiallySignedTransaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public PSBT Combine(PSBT other)
367367
/// </summary>
368368
/// <param name="other">Another PSBT to takes information from</param>
369369
/// <returns>This instance</returns>
370-
public PSBT UpdateFrom(PSBT other)
370+
public virtual PSBT UpdateFrom(PSBT other)
371371
{
372372
if (other == null)
373373
{

NBitcoin/BIP370/PSBT2.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,17 @@ public PSBT2Output AddOutput(Money value, Script scriptPubKey)
191191
txOut.ScriptPubKey = scriptPubKey;
192192
return new PSBT2Output(value, scriptPubKey, this, (uint)Inputs.Count);
193193
}
194+
public override PSBT UpdateFrom(PSBT other)
195+
{
196+
if (other is PSBT2 o)
197+
{
198+
if (o.FallbackLockTime is { } fallbackLockTime)
199+
FallbackLockTime = fallbackLockTime;
200+
if (o.ModifiableFlags is { } modifiableFlags)
201+
ModifiableFlags = modifiableFlags;
202+
}
203+
return base.UpdateFrom(other);
204+
}
194205

195206
protected override void WriteCore(JsonTextWriter jsonWriter)
196207
{

NBitcoin/BIP370/PSBT2Input.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ internal static void FillMap(Map m, TxIn input)
1515
m.Add([PSBT2Constants.PSBT_IN_PREVIOUS_TXID], input.PrevOut.Hash.ToBytes());
1616
}
1717

18+
public override void UpdateFrom(PSBTInput other)
19+
{
20+
if (other is PSBT2Input o)
21+
{
22+
if (o.Sequence != Sequence.Final)
23+
Sequence = o.Sequence;
24+
if (o.LockTime is { } lockTime)
25+
LockTime = lockTime;
26+
if (o.LockTimeHeight is { } lockTimeHeight)
27+
LockTimeHeight = lockTimeHeight;
28+
}
29+
base.UpdateFrom(other);
30+
}
31+
1832
DateTimeOffset? _LockTime;
1933
public DateTimeOffset? LockTime
2034
{

0 commit comments

Comments
 (0)