Class LoanSigningHelper
Helper for LoanSet multi-party signing (XLS-66d).
LoanSet carries two signatures: the submitter (Account) signs the transaction itself
(TxnSignature), and the counterparty provides a CounterpartySignature (inner STObject with
SigningPubKey + TxnSignature, or Signers).
The roles are not tied to broker and borrower. The counterparty is the Counterparty
field, or the LoanBroker's owner when the field is omitted; one of Account and the
counterparty must be the broker owner, and the other one is the borrower (rippled
LoanSet::preclaim and LoanSet::checkSign). Either the broker owner submits and
the borrower co-signs, or the borrower submits and the broker owner co-signs.
Three signing patterns (analogous to Batch V1/V2/V3):
V1 — Automatic (both keys available):
var result = LoanSigningHelper.SignLoanSet(loanTx, submitterWallet, counterpartyWallet);
await client.SubmitRequest(result.TxBlob);
V2 — Parallel (keys on separate devices, sign independently):
// Device A (counterparty):
var counterpartySig = counterpartyWallet.SignAsLoanCounterparty(preparedTxJson);
// Device B (submitter):
var submitterSig = submitterWallet.Sign(preparedTxJson);
// Combiner:
var combined = LoanSigningHelper.CombineLoanSignatures(submitterSig.TxBlob, counterpartySig.TxBlob);
await client.SubmitRequest(combined);
V3 — Sequential (counterparty signs first, passes to the submitter):
// Counterparty signs, adds CounterpartySignature:
var withCounterparty = counterpartyWallet.SignAsLoanCounterparty(preparedTxJson);
// Submitter receives the partially signed blob, adds TxnSignature:
var final = LoanSigningHelper.SubmitterSign(withCounterparty.TxBlob, submitterWallet);
await client.SubmitRequest(final.TxBlob);
Multisig counterparty (a counterparty with a SignerList): each signer of the
counterparty's list produces a portable Signer entry with the standard multisign
call, and the composer places them under CounterpartySignature.Signers
(rippled verifies them against the counterparty's SignerList over the same
multisign preimage as tx.Signers). Autofill with the signer count so the
fee covers them (rippled LoanSet::calculateBaseFee charges one base fee
per counterparty signer):
var prepared = LoanSigningHelper.PrepareForSigning(await client.Autofill(loanTx.ToDictionary(), signersCount: 2), submitterWallet);
var submitterPart = submitterWallet.Sign(prepared);
var part1 = signer1.Sign(prepared, multisign: true);
var part2 = signer2.Sign(prepared, multisign: true);
// ledger-driven routing (looks up the counterparty's SignerList):
var composed = await client.ComposeSignatures(new[] { submitterPart.TxBlob, part1.TxBlob, part2.TxBlob });
// or offline, naming the counterparty's signers:
var offline = LoanSigningHelper.CombineLoanSignatures(new[] { submitterPart.TxBlob, part1.TxBlob, part2.TxBlob }, new[] { signer1.ClassicAddress, signer2.ClassicAddress });
Inheritance
Namespace: Xrpl.Wallet
Assembly: Xrpl.dll
Syntax
public static class LoanSigningHelper
Methods
| Edit this page View SourceBrokerSign(string, XrplWallet)
V3 — The submitter signs a partially signed LoanSet blob. Same as SubmitterSign(string, XrplWallet): the submitter need not be the broker.
Declaration
[Obsolete("Use SubmitterSign: the account that submits a LoanSet may be the borrower as well as the broker owner.")]
public static SignatureResult BrokerSign(string partiallySignedBlob, XrplWallet brokerWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| string | partiallySignedBlob | Hex blob from the counterparty's SignAsLoanCounterparty (has CounterpartySignature, no TxnSignature). |
| XrplWallet | brokerWallet | The submitting account's wallet ( |
Returns
| Type | Description |
|---|---|
| SignatureResult | Fully signed transaction blob and hash. |
CombineLoanSignatures(IEnumerable<string>, IReadOnlyCollection<string>)
Combines a submitter part with the portable Signer entries of a multisig
counterparty: entries from counterpartySignerAccounts land in
CounterpartySignature.Signers, any other entry in tx.Signers
(a multisig submitter). Offline; for ledger-driven routing use
IXrplClient.ComposeSignatures.
Declaration
public static SignatureResult CombineLoanSignatures(IEnumerable<string> partBlobs, IReadOnlyCollection<string> counterpartySignerAccounts)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<string> | partBlobs | The submitter's blob and the counterparty-side multisign parts. |
| IReadOnlyCollection<string> | counterpartySignerAccounts | Accounts of the counterparty's SignerList. |
Returns
| Type | Description |
|---|---|
| SignatureResult |
CombineLoanSignatures(string, string)
V2 — Combine independently signed submitter and counterparty blobs. The submitter blob has TxnSignature but no CounterpartySignature. The counterparty blob has CounterpartySignature but no TxnSignature.
Declaration
public static SignatureResult CombineLoanSignatures(string submitterSignedBlob, string counterpartySignedBlob)
Parameters
| Type | Name | Description |
|---|---|---|
| string | submitterSignedBlob | Hex blob signed by the submitting account (has TxnSignature). |
| string | counterpartySignedBlob | Hex blob signed by the counterparty (has CounterpartySignature). |
Returns
| Type | Description |
|---|---|
| SignatureResult | Combined fully signed blob. |
PrepareForSigning(JsonObject, XrplWallet)
Prepares a LoanSet JSON object for signing.
Declaration
public static JsonObject PrepareForSigning(JsonObject txJson, XrplWallet submitterWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | txJson | The LoanSet transaction JSON. |
| XrplWallet | submitterWallet | The wallet of the submitting account ( |
Returns
| Type | Description |
|---|---|
| JsonObject |
PrepareForSigning(ITransactionRequest, XrplWallet)
Prepares a LoanSet transaction JSON for signing. Sets SigningPubKey to the submitter's public key and removes signature fields. Returns a JsonObject ready for both parties to sign.
Declaration
public static JsonObject PrepareForSigning(ITransactionRequest loanSetTx, XrplWallet submitterWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| ITransactionRequest | loanSetTx | The LoanSet transaction (autofilled with Sequence, Fee, LastLedgerSequence). |
| XrplWallet | submitterWallet | The wallet of the submitting account ( |
Returns
| Type | Description |
|---|---|
| JsonObject | JsonObject ready for signing by both parties. |
Remarks
Fee for CounterpartySignature overhead is handled by Autofill
(see CalculateBaseFeeForType in Autofill.cs).
SignLoanSet(JsonObject, XrplWallet, XrplWallet)
V1 — Automatic signing: both wallets available locally. Computes the signing preimages, has both parties sign, and returns the fully signed tx blob.
Declaration
public static SignatureResult SignLoanSet(JsonObject preparedTx, XrplWallet submitterWallet, XrplWallet counterpartyWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | preparedTx | Prepared LoanSet JSON (from PrepareForSigning or already prepared). |
| XrplWallet | submitterWallet | The submitting account's wallet ( |
| XrplWallet | counterpartyWallet | The counterparty's wallet. |
Returns
| Type | Description |
|---|---|
| SignatureResult | Fully signed transaction blob and hash. |
Remarks
The two wallets may be passed in either order: the one whose address is Account
signs the transaction (TxnSignature), the other signs CounterpartySignature. The other
wallet must be the counterparty: the Counterparty field when present. When the
field is omitted the node takes the LoanBroker's owner as the counterparty, which this
offline overload cannot check; pass the owner through
SignLoanSet(JsonObject, XrplWallet, XrplWallet, string) to have it checked
here rather than rejected by the node as an invalid counterparty signature.
SignLoanSet(JsonObject, XrplWallet, XrplWallet, string)
V1 — Automatic signing with the LoanBroker's owner known, so the roles are checked the way rippled checks them before anything is signed.
Declaration
public static SignatureResult SignLoanSet(JsonObject preparedTx, XrplWallet submitterWallet, XrplWallet counterpartyWallet, string brokerOwner)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | preparedTx | Prepared LoanSet JSON (from PrepareForSigning or already prepared). |
| XrplWallet | submitterWallet | The submitting account's wallet ( |
| XrplWallet | counterpartyWallet | The counterparty's wallet. |
| string | brokerOwner | The LoanBroker's owner, or null to skip the owner checks. |
Returns
| Type | Description |
|---|---|
| SignatureResult | Fully signed transaction blob and hash. |
Remarks
The counterparty is Counterparty, or brokerOwner when the field
is omitted (rippled LoanSet::checkSign), and one of Account and the
counterparty must be the broker owner (rippled LoanSet::preclaim,
tecNO_PERMISSION otherwise). The wallets may be passed in either order. The owner
is the Owner of the LoanBroker ledger entry named by LoanBrokerID.
SubmitterSign(string, XrplWallet)
V3 — The submitter signs a partially signed LoanSet blob (one that already has CounterpartySignature). Decodes the blob, strips CounterpartySignature to compute the correct preimage, adds the submitter's TxnSignature, then restores CounterpartySignature for encoding.
Declaration
public static SignatureResult SubmitterSign(string partiallySignedBlob, XrplWallet submitterWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| string | partiallySignedBlob | Hex blob from the counterparty's SignAsLoanCounterparty (has CounterpartySignature, no TxnSignature). |
| XrplWallet | submitterWallet | The submitting account's wallet ( |
Returns
| Type | Description |
|---|---|
| SignatureResult | Fully signed transaction blob and hash. |