Constructor
new AnyHedgeManager(config)
- See:
-
- AnyHedge contracts repository for a list of contract versions.
Initializes an AnyHedge Manager using the specified config options. Note that the `networkProvider` and `electrumCluster`
options are mutually exclusive and the `networkProvider` takes precedence. The default network provider automatically
connects and disconnects between network requests, so if you need a persistent connection, please use a custom provider.
Examples
const anyHedgeManager = new AnyHedgeManager({ authenticationToken: '<token>' });
const config =
{
authenticationToken: '<token>',
serviceDomain: 'localhost',
servicePort: 6572,
serviceScheme: 'http',
networkProvider: new ElectrumNetworkProvider('mainnet')
};
const anyHedgeManager = new AnyHedgeManager(config);
Parameters:
Name | Type | Description |
---|---|---|
config |
AnyHedgeManagerConfig | config object containing configuration options for the AnyHedge Manager. |
Classes
Methods
(async) addContractFee(contractData, contractFee)
Adds a new fee to a set of contract data, allowing services to define their fees before registering with a settlement service.
Parameters:
Name | Type | Description |
---|---|---|
contractData |
contract data to add a fee to. | |
contractFee |
the fee to add to the contract data. |
Returns:
an updated contractData including the added fee.
(async) addContractFee(contractData, contractFee)
Adds a new fee to a set of contract data, allowing services to define their fees before registering with a settlement service.
Parameters:
Name | Type | Description |
---|---|---|
contractData |
contract data to add a fee to. | |
contractFee |
the fee to add to the contract data. |
Returns:
an updated contractData including the added fee.
calculateTotalRequiredFundingSatoshis(contractData)
Calculate the total satoshis required as input to a collaborative funding transaction.
This includes the contract input satoshis, contract safety fees, potential settlement
service fees and funding transaction fees. This assumes 2 P2PKH inputs to the funding
transaction.
Parameters:
Name | Type | Description |
---|---|---|
contractData |
contract data for which to calculate funding satoshis |
Returns:
total required funding satoshis
calculateTotalRequiredFundingSatoshis(contractData)
Calculate the total satoshis required as input to a collaborative funding transaction.
This includes the contract input satoshis, contract safety fees, potential settlement
service fees and funding transaction fees. This assumes 2 P2PKH inputs to the funding
transaction.
Parameters:
Name | Type | Description |
---|---|---|
contractData |
contract data for which to calculate funding satoshis |
Returns:
total required funding satoshis
(async) completeFundingProposal(signedProposal1, signedProposal2)
Complete a funding by combining two signed funding proposals and returning the resulting transaction hex.
Parameters:
Name | Type | Description |
---|---|---|
signedProposal1 |
first signed proposal. | |
signedProposal2 |
second signed proposal. |
Throws:
-
-
if total provided satoshis is not exactly the total required satoshis.
- Type
- Error
-
-
-
if the two funding proposals belong to different contracts.
- Type
- Error
-
Returns:
transaction ID for the broadcasted funding transaction.
(async) completeFundingProposal(signedProposal1, signedProposal2)
Complete a funding by combining two signed funding proposals and returning the resulting transaction hex.
Parameters:
Name | Type | Description |
---|---|---|
signedProposal1 |
first signed proposal. | |
signedProposal2 |
second signed proposal. |
Throws:
-
-
if total provided satoshis is not exactly the total required satoshis.
- Type
- Error
-
-
-
if the two funding proposals belong to different contracts.
- Type
- Error
-
Returns:
transaction ID for the broadcasted funding transaction.
(async) completeMutualRedemption(signedProposal1, signedProposal2, contractParameters)
Complete a mutual redemption by generating a valid transaction from both parties'
signed proposals and broadcasting it. Both parties need to generate and sign the same
transaction proposal using signMutualEarlyMaturation(), signMutualRefund() or
signMutualArbitraryPayout().
Parameters:
Name | Type | Description |
---|---|---|
signedProposal1 |
transaction proposal signed by one of the two parties. | |
signedProposal2 |
transaction proposal signed by the other party. | |
contractParameters |
contract parameters for the relevant contract. |
Throws:
-
-
if any proposal is unsigned.
- Type
- Error
-
-
-
if the transaction details of both proposals don't match.
- Type
- Error
-
-
-
if the redemption data lists of the proposals have different lengths.
- Type
- Error
-
-
-
if both proposals are signed by the same party.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) completeMutualRedemption(signedProposal1, signedProposal2, contractParameters)
Complete a mutual redemption by generating a valid transaction from both parties'
signed proposals and broadcasting it. Both parties need to generate and sign the same
transaction proposal using signMutualEarlyMaturation(), signMutualRefund() or
signMutualArbitraryPayout().
Parameters:
Name | Type | Description |
---|---|---|
signedProposal1 |
transaction proposal signed by one of the two parties. | |
signedProposal2 |
transaction proposal signed by the other party. | |
contractParameters |
contract parameters for the relevant contract. |
Throws:
-
-
if any proposal is unsigned.
- Type
- Error
-
-
-
if the transaction details of both proposals don't match.
- Type
- Error
-
-
-
if the redemption data lists of the proposals have different lengths.
- Type
- Error
-
-
-
if both proposals are signed by the same party.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) createContract(contractCreationParameters) → {Promise.<ContractData>}
Creates a new contract.
Parameters:
Name | Type | Description |
---|---|---|
contractCreationParameters |
ContractCreationParameters | object containing the parameters to create this contract. |
Returns:
the contract parameters and metadata.
- Type
- Promise.<ContractData>
(async) createContract(contractCreationParameters) → {Promise.<ContractData>}
Creates a new contract.
Parameters:
Name | Type | Description |
---|---|---|
contractCreationParameters |
ContractCreationParameters | object containing the parameters to create this contract. |
Returns:
the contract parameters and metadata.
- Type
- Promise.<ContractData>
createFundingProposal(contractData, outpointTransactionHash, outpointIndex, satoshis)
Create an unsigned funding proposal.
Parameters:
Name | Type | Description |
---|---|---|
contractData |
contract data for the proposal | |
outpointTransactionHash |
outpoint transaction hash of the UTXO for the proposal | |
outpointIndex |
outpoint index of the UTXO for the proposal | |
satoshis |
satoshi amount of the UTXO for the proposal |
Returns:
unsigned funding proposal created from the provided data.
createFundingProposal(contractData, outpointTransactionHash, outpointIndex, satoshis)
Create an unsigned funding proposal.
Parameters:
Name | Type | Description |
---|---|---|
contractData |
contract data for the proposal | |
outpointTransactionHash |
outpoint transaction hash of the UTXO for the proposal | |
outpointIndex |
outpoint index of the UTXO for the proposal | |
satoshis |
satoshi amount of the UTXO for the proposal |
Returns:
unsigned funding proposal created from the provided data.
(async) custodialMutualArbitraryPayout(hedgePrivateKeyWIF, longPrivateKeyWIF, transactionProposal, contractParameters)
Build and broadcast a custodial mutual redemption transaction with arbitrary transaction details.
Parameters:
Name | Type | Description |
---|---|---|
hedgePrivateKeyWIF |
hedge's private key WIF. | |
longPrivateKeyWIF |
long's private key WIF. | |
transactionProposal |
unsigned transaction proposal for the mutual redemption. | |
contractParameters |
contract parameters of the relevant contract. |
Throws:
-
-
if any of the private key WIF strings is not valid.
- Type
- Error
-
-
-
if any of the private key WIFs does not belong to a party of the contract.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) custodialMutualArbitraryPayout(hedgePrivateKeyWIF, longPrivateKeyWIF, transactionProposal, contractParameters)
Build and broadcast a custodial mutual redemption transaction with arbitrary transaction details.
Parameters:
Name | Type | Description |
---|---|---|
hedgePrivateKeyWIF |
hedge's private key WIF. | |
longPrivateKeyWIF |
long's private key WIF. | |
transactionProposal |
unsigned transaction proposal for the mutual redemption. | |
contractParameters |
contract parameters of the relevant contract. |
Throws:
-
-
if any of the private key WIF strings is not valid.
- Type
- Error
-
-
-
if any of the private key WIFs does not belong to a party of the contract.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) custodialMutualEarlyMaturation(hedgePrivateKeyWIF, longPrivateKeyWIF, contractFunding, settlementPrice, contractParameters)
Build and broadcast a custodial mutual redemption transaction that mimics a
maturation before the actual maturation timestamp.
Parameters:
Name | Type | Description |
---|---|---|
hedgePrivateKeyWIF |
hedge's private key WIF. | |
longPrivateKeyWIF |
long's private key WIF. | |
contractFunding |
the specific Contract Funding to use in the custodial early maturation. | |
settlementPrice |
price to use in settlement. | |
contractParameters |
contract parameters of the relevant contract. |
Throws:
-
-
if any of the private key WIF strings is not valid.
- Type
- Error
-
-
-
if any of the private key WIFs does not belong to a party of the contract.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) custodialMutualEarlyMaturation(hedgePrivateKeyWIF, longPrivateKeyWIF, contractFunding, settlementPrice, contractParameters)
Build and broadcast a custodial mutual redemption transaction that mimics a
maturation before the actual maturation timestamp.
Parameters:
Name | Type | Description |
---|---|---|
hedgePrivateKeyWIF |
hedge's private key WIF. | |
longPrivateKeyWIF |
long's private key WIF. | |
contractFunding |
the specific Contract Funding to use in the custodial early maturation. | |
settlementPrice |
price to use in settlement. | |
contractParameters |
contract parameters of the relevant contract. |
Throws:
-
-
if any of the private key WIF strings is not valid.
- Type
- Error
-
-
-
if any of the private key WIFs does not belong to a party of the contract.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) custodialMutualRefund(hedgePrivateKeyWIF, longPrivateKeyWIF, contractFunding, contractParameters, contractMetadata, hedgeRefundAddressopt, longRefundAddressopt)
Build and broadcast a custodial mutual redemption transaction that refunds
the contract's funds based on the provided contract metadata. Optionally
allows you to provide separate refund addresses. If these are omitted,
the mutual redemption public keys are used to receive the refunds.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
hedgePrivateKeyWIF |
hedge's private key WIF. | ||
longPrivateKeyWIF |
long's private key WIF. | ||
contractFunding |
the specific Contract Funding to use in the custodial refund. | ||
contractParameters |
contract parameters of the relevant contract. | ||
contractMetadata |
contract metadata of the relevant contract. | ||
hedgeRefundAddress |
<optional> |
hedge's address to receive the refund. | |
longRefundAddress |
<optional> |
long's address to receive the refund. |
Throws:
-
-
if any of the private key WIF strings is not valid.
- Type
- Error
-
-
-
if any of the private key WIFs does not belong to a party of the contract.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) custodialMutualRefund(hedgePrivateKeyWIF, longPrivateKeyWIF, contractFunding, contractParameters, contractMetadata, hedgeRefundAddressopt, longRefundAddressopt)
Build and broadcast a custodial mutual redemption transaction that refunds
the contract's funds based on the provided contract metadata. Optionally
allows you to provide separate refund addresses. If these are omitted,
the mutual redemption public keys are used to receive the refunds.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
hedgePrivateKeyWIF |
hedge's private key WIF. | ||
longPrivateKeyWIF |
long's private key WIF. | ||
contractFunding |
the specific Contract Funding to use in the custodial refund. | ||
contractParameters |
contract parameters of the relevant contract. | ||
contractMetadata |
contract metadata of the relevant contract. | ||
hedgeRefundAddress |
<optional> |
hedge's address to receive the refund. | |
longRefundAddress |
<optional> |
long's address to receive the refund. |
Throws:
-
-
if any of the private key WIF strings is not valid.
- Type
- Error
-
-
-
if any of the private key WIFs does not belong to a party of the contract.
- Type
- Error
-
-
-
if the generated transaction could not successfully be broadcasted.
- Type
- Error
-
Returns:
transaction ID of the broadcasted mutual redemption transaction.
(async) getContractFundings(contractParameters)
Retrieve a list of all ContractFunding instances for a contract.
Parameters:
Name | Type | Description |
---|---|---|
contractParameters |
Contract parameters for the relevant contract. |
Returns:
list of contract fundings for a contract.
(async) getContractFundings(contractParameters)
Retrieve a list of all ContractFunding instances for a contract.
Parameters:
Name | Type | Description |
---|---|---|
contractParameters |
Contract parameters for the relevant contract. |
Returns:
list of contract fundings for a contract.
(async) getContractStatus(contractAddress, privateKeyWIFopt)
Request the contract data and status of a contract with the settlement service.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
contractAddress |
address to retrieve status for | ||
privateKeyWIF |
<optional> |
private key WIF of one of the contract's parties. |
Throws:
-
-
if no authentication token is provided or the authentication token is invalid.
- Type
- Error
-
-
-
if no private key WIF was provided *and* the authentication token is different than the one used for registration.
- Type
- Error
-
-
-
if an invalid WIF was provided.
- Type
- Error
-
-
-
if a private key WIF was provided that does not belong to either of the contract parties.
- Type
- Error
-
-
-
if no contract is registered at the settlement service for the given address.
- Type
- Error
-
-
-
if the API call is unsuccessful.
- Type
- Error
-
Returns:
the contract data and status of the contract
(async) getContractStatus(contractAddress, privateKeyWIFopt)
Request the contract data and status of a contract with the settlement service.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
contractAddress |
address to retrieve status for | ||
privateKeyWIF |
<optional> |
private key WIF of one of the contract's parties. |
Throws:
-
-
if no authentication token is provided or the authentication token is invalid.
- Type
- Error
-
-
-
if no private key WIF was provided *and* the authentication token is different than the one used for registration.
- Type
- Error
-
-
-
if an invalid WIF was provided.
- Type
- Error
-
-
-
if a private key WIF was provided that does not belong to either of the contract parties.
- Type
- Error
-
-
-
if no contract is registered at the settlement service for the given address.
- Type
- Error
-
-
-
if the API call is unsuccessful.
- Type
- Error
-
Returns:
the contract data and status of the contract
(async) liquidateContractFunding(contractLiquidationParameters)
Liquidates a contract.
Parameters:
Name | Type | Description |
---|---|---|
contractLiquidationParameters |
object containing the parameters to liquidate this contract. |
Returns:
ContractSettlement object containing the details of the liquidation.
(async) liquidateContractFunding(contractLiquidationParameters)
Liquidates a contract.
Parameters:
Name | Type | Description |
---|---|---|
contractLiquidationParameters |
object containing the parameters to liquidate this contract. |
Returns:
ContractSettlement object containing the details of the liquidation.
(async) matureContractFunding(contractMaturationParameters)
Matures a contract.
Parameters:
Name | Type | Description |
---|---|---|
contractMaturationParameters |
object containing the parameters to mature this contract. |
Returns:
ContractSettlement object containing the details of the maturation.
(async) matureContractFunding(contractMaturationParameters)
Matures a contract.
Parameters:
Name | Type | Description |
---|---|---|
contractMaturationParameters |
object containing the parameters to mature this contract. |
Returns:
ContractSettlement object containing the details of the maturation.
(async) parseSettlementTransaction(settlementTransactionHex)
Parse a settlement transaction to extract as much data as possible, ending up with
ContractParameters, ContractSettlement and ContractFunding objects, depending on what data
could be retrieved.
Parameters:
Name | Type | Description |
---|---|---|
settlementTransactionHex |
hex string for the settlement transaction |
Throws:
-
-
when the passed transaction hex cannot be parsed by Libauth.
- Type
- Error
-
-
-
if the transaction does not have exactly one input.
- Type
- SettlementParseError
-
-
-
if the transaction does not have exactly two outputs.
- Type
- SettlementParseError
-
-
-
if the unlocking script does not include exactly 6 or 10 input parameters.
- Type
- SettlementParseError
-
-
-
if the redeem script does not match expectations for an AnyHedge contract.
- Type
- SettlementParseError
-
Returns:
ContractParameters, ContractSettlement, and ContractFunding objects. See examples/parse-settlement-transaction.js to inspect the data that this function returns.
(async) parseSettlementTransaction(settlementTransactionHex)
Parse a settlement transaction to extract as much data as possible, ending up with
ContractParameters, ContractSettlement and ContractFunding objects, depending on what data
could be retrieved.
Parameters:
Name | Type | Description |
---|---|---|
settlementTransactionHex |
hex string for the settlement transaction |
Throws:
-
-
when the passed transaction hex cannot be parsed by Libauth.
- Type
- Error
-
-
-
if the transaction does not have exactly one input.
- Type
- SettlementParseError
-
-
-
if the transaction does not have exactly two outputs.
- Type
- SettlementParseError
-
-
-
if the unlocking script does not include exactly 6 or 10 input parameters.
- Type
- SettlementParseError
-
-
-
if the redeem script does not match expectations for an AnyHedge contract.
- Type
- SettlementParseError
-
Returns:
ContractParameters, ContractSettlement, and ContractFunding objects. See examples/parse-settlement-transaction.js to inspect the data that this function returns.
(async) registerContractForSettlement(contractRegistrationParameters)
Register a new contract for external management.
Parameters:
Name | Type | Description |
---|---|---|
contractRegistrationParameters |
object containing the parameters to register this contract. |
Throws:
-
if no authentication token is provided or the authentication token is invalid.
- Type
- Error
Returns:
contract information for the registered contract.
(async) registerContractForSettlement(contractRegistrationParameters)
Register a new contract for external management.
Parameters:
Name | Type | Description |
---|---|---|
contractRegistrationParameters |
object containing the parameters to register this contract. |
Throws:
-
if no authentication token is provided or the authentication token is invalid.
- Type
- Error
Returns:
contract information for the registered contract.
(async) requestAuthenticationToken(name)
Request an authentication token from the settlement service. This token
is used to authenticate all requests to the settlement services. Only a single
token needs to be generated per consuming application.
Parameters:
Name | Type | Description |
---|---|---|
name |
name to communicate an identity to the settlement service. |
Throws:
-
if the request failed.
- Type
- Error
Returns:
a new authentication token
(async) requestAuthenticationToken(name)
Request an authentication token from the settlement service. This token
is used to authenticate all requests to the settlement services. Only a single
token needs to be generated per consuming application.
Parameters:
Name | Type | Description |
---|---|---|
name |
name to communicate an identity to the settlement service. |
Throws:
-
if the request failed.
- Type
- Error
Returns:
a new authentication token
(async) settleContractFunding(contractSettlementParameters)
Settles a contract (this includes both maturation and liquidation).
Parameters:
Name | Type | Description |
---|---|---|
contractSettlementParameters |
object containing the parameters to settle this contract. |
Returns:
ContractSettlement object containing the details of the settlement.
(async) settleContractFunding(contractSettlementParameters)
Settles a contract (this includes both maturation and liquidation).
Parameters:
Name | Type | Description |
---|---|---|
contractSettlementParameters |
object containing the parameters to settle this contract. |
Returns:
ContractSettlement object containing the details of the settlement.
(async) signFundingProposal(privateKeyWIF, fundingProposal)
Sign a partial funding transaction for a contract and add the signature and public key to the proposal.
Parameters:
Name | Type | Description |
---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | |
fundingProposal |
An unsigned proposal for a contract funding. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if a valid transaction is generated during the preparation.
- Type
- Error
-
Returns:
updated transaction proposal with the resolved variables added in.
(async) signFundingProposal(privateKeyWIF, fundingProposal)
Sign a partial funding transaction for a contract and add the signature and public key to the proposal.
Parameters:
Name | Type | Description |
---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | |
fundingProposal |
An unsigned proposal for a contract funding. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if a valid transaction is generated during the preparation.
- Type
- Error
-
Returns:
updated transaction proposal with the resolved variables added in.
(async) signMutualArbitraryPayout(privateKeyWIF, transactionProposal, contractParameters)
Sign a mutual redemption transaction proposal with arbitrary transaction details.
Both parties need to call this function with the same transaction details.
Both signed transaction proposals must then be passed into the
completeMutualRedemption() function to broadcast the transaction.
Parameters:
Name | Type | Description |
---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | |
transactionProposal |
An unsigned proposal for a transaction. | |
contractParameters |
contract parameters for the relevant contract. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if the private key WIF does not belong to a party of the contract.
- Type
- Error
-
-
-
if a valid transaction is generated during the preparation.
- Type
- Error
-
Returns:
updated transaction proposal with the resolved variables added in.
(async) signMutualArbitraryPayout(privateKeyWIF, transactionProposal, contractParameters)
Sign a mutual redemption transaction proposal with arbitrary transaction details.
Both parties need to call this function with the same transaction details.
Both signed transaction proposals must then be passed into the
completeMutualRedemption() function to broadcast the transaction.
Parameters:
Name | Type | Description |
---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | |
transactionProposal |
An unsigned proposal for a transaction. | |
contractParameters |
contract parameters for the relevant contract. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if the private key WIF does not belong to a party of the contract.
- Type
- Error
-
-
-
if a valid transaction is generated during the preparation.
- Type
- Error
-
Returns:
updated transaction proposal with the resolved variables added in.
(async) signMutualEarlyMaturation(privateKeyWIF, contractFunding, settlementPrice, contractParameters)
Sign a mutual redemption transaction that mimics a maturation before the
actual maturation timestamp. Both parties need to call this function with
the same input and settlement price. Both signed transaction proposals must then
be passed into the completeMutualRedemption() function to broadcast the transaction.
Parameters:
Name | Type | Description |
---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | |
contractFunding |
the specific Contract Funding to use in the mutual early maturation. | |
settlementPrice |
price to use in settlement. | |
contractParameters |
contract parameters of the relevant contract. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if the private key WIF does not belong to a party of the contract.
- Type
- Error
-
Returns:
a signed settlement transaction proposal.
(async) signMutualEarlyMaturation(privateKeyWIF, contractFunding, settlementPrice, contractParameters)
Sign a mutual redemption transaction that mimics a maturation before the
actual maturation timestamp. Both parties need to call this function with
the same input and settlement price. Both signed transaction proposals must then
be passed into the completeMutualRedemption() function to broadcast the transaction.
Parameters:
Name | Type | Description |
---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | |
contractFunding |
the specific Contract Funding to use in the mutual early maturation. | |
settlementPrice |
price to use in settlement. | |
contractParameters |
contract parameters of the relevant contract. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if the private key WIF does not belong to a party of the contract.
- Type
- Error
-
Returns:
a signed settlement transaction proposal.
(async) signMutualRefund(privateKeyWIF, contractFunding, contractParameters, contractMetadata, hedgeRefundAddressopt, longRefundAddressopt)
Sign a mutual redemption transaction that refunds the contract's funds based on
the provided contract metadata. Optionally allows you to provide separate
refund addresses. If these are omitted, the mutual redemption public keys
are used to receive the refunds. Both parties need to call this function with
the same contract funding, contract metadata and refund addresses. Both signed
transaction proposals must then be passed into the completeMutualRedemption()
function to broadcast the transaction.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | ||
contractFunding |
the specific Contract Funding to use in the mutual refund. | ||
contractParameters |
contract parameters of the relevant contract. | ||
contractMetadata |
contract metadata of the relevant contract. | ||
hedgeRefundAddress |
<optional> |
hedge's address to receive the refund. | |
longRefundAddress |
<optional> |
long's address to receive the refund. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if the private key WIF does not belong to a party of the contract.
- Type
- Error
-
Returns:
a signed refund transaction proposal.
(async) signMutualRefund(privateKeyWIF, contractFunding, contractParameters, contractMetadata, hedgeRefundAddressopt, longRefundAddressopt)
Sign a mutual redemption transaction that refunds the contract's funds based on
the provided contract metadata. Optionally allows you to provide separate
refund addresses. If these are omitted, the mutual redemption public keys
are used to receive the refunds. Both parties need to call this function with
the same contract funding, contract metadata and refund addresses. Both signed
transaction proposals must then be passed into the completeMutualRedemption()
function to broadcast the transaction.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
privateKeyWIF |
private key WIF of one of the contract's parties. | ||
contractFunding |
the specific Contract Funding to use in the mutual refund. | ||
contractParameters |
contract parameters of the relevant contract. | ||
contractMetadata |
contract metadata of the relevant contract. | ||
hedgeRefundAddress |
<optional> |
hedge's address to receive the refund. | |
longRefundAddress |
<optional> |
long's address to receive the refund. |
Throws:
-
-
if the private key WIF string is not valid.
- Type
- Error
-
-
-
if the private key WIF does not belong to a party of the contract.
- Type
- Error
-
Returns:
a signed refund transaction proposal.
(async) submitFundingTransaction(contractAddress, transactionHex, dependencyTransactionsopt)
Register a new contract for external management.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
contractAddress |
contract address to submit funding for. | ||
transactionHex |
funding transaction as a hex-encoded string. | ||
dependencyTransactions |
<optional> |
list of transaction hex strings of transactions that the funding transaction depends on. |
Throws:
-
-
if no authentication token is provided or the authentication token is invalid.
- Type
- Error
-
-
-
if the API call failed in any way (e.g. the transaction failed to broadcast).
- Type
- Error
-
Returns:
funding information for the registered contract.
(async) submitFundingTransaction(contractAddress, transactionHex, dependencyTransactionsopt)
Register a new contract for external management.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
contractAddress |
contract address to submit funding for. | ||
transactionHex |
funding transaction as a hex-encoded string. | ||
dependencyTransactions |
<optional> |
list of transaction hex strings of transactions that the funding transaction depends on. |
Throws:
-
-
if no authentication token is provided or the authentication token is invalid.
- Type
- Error
-
-
-
if the API call failed in any way (e.g. the transaction failed to broadcast).
- Type
- Error
-
Returns:
funding information for the registered contract.
(async) validateContract(contractValidationParameters)
Validates that a given contract address matches specific contract parameters.
Parameters:
Name | Type | Description |
---|---|---|
contractValidationParameters |
object containing the parameters to validate this contract. |
Returns:
true if the contract address and parameters match, otherwise false.
(async) validateContract(contractValidationParameters)
Validates that a given contract address matches specific contract parameters.
Parameters:
Name | Type | Description |
---|---|---|
contractValidationParameters |
object containing the parameters to validate this contract. |
Returns:
true if the contract address and parameters match, otherwise false.