Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Support network arg for adding signatures to transaction #389

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions stellar-dotnet-sdk/TransactionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public void Sign(byte[] preimage)
/// </summary>
/// <param name="publicKey">The public key of the signer</param>
/// <param name="signature">The base64 value of the signature XDR</param>
public void Sign(string publicKey, string signature)
/// <param name="network">The network <see cref="Network"/> the transaction will be sent to.</param>
public void Sign(string publicKey, string signature, Network? network = null)
{
if (publicKey == null)
throw new ArgumentNullException(nameof(publicKey), "public key cannot be null");
Expand All @@ -138,7 +139,7 @@ public void Sign(string publicKey, string signature)
throw new ArgumentException("Invalid public key", nameof(publicKey));
}

if (!keyPair.Verify(Hash(), signatureObj.InnerValue))
if (!keyPair.Verify(Hash(network ?? Network.Current), signatureObj.InnerValue))
throw new ArgumentException("Invalid signature", nameof(signature));

var decoratedSignature = new DecoratedSignature
Expand Down Expand Up @@ -196,4 +197,4 @@ public string ToEnvelopeXdrBase64(TransactionXdrVersion version = TransactionXdr
}

}
}
}