Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atomicfinance/client

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atomicfinance/client - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0-alpha.0

LICENSE

109

dist/Dlc.d.ts
import Client from './Client';
import { AddSignaturesToRefundTxRequest, AddSignaturesToRefundTxResponse, AddSignatureToFundTransactionRequest, AddSignatureToFundTransactionResponse, CreateCetAdaptorSignatureRequest, CreateCetAdaptorSignatureResponse, CreateCetAdaptorSignaturesRequest, CreateCetAdaptorSignaturesResponse, CreateCetRequest, CreateCetResponse, CreateDlcTransactionsRequest, CreateDlcTransactionsResponse, CreateFundTransactionRequest, CreateFundTransactionResponse, CreateRefundTransactionRequest, CreateRefundTransactionResponse, GetRawFundTxSignatureRequest, GetRawFundTxSignatureResponse, GetRawRefundTxSignatureRequest, GetRawRefundTxSignatureResponse, SignCetRequest, SignCetResponse, SignFundTransactionRequest, SignFundTransactionResponse, VerifyCetAdaptorSignatureRequest, VerifyCetAdaptorSignatureResponse, VerifyCetAdaptorSignaturesRequest, VerifyCetAdaptorSignaturesResponse, VerifyFundTxSignatureRequest, VerifyFundTxSignatureResponse, VerifyRefundTxSignatureRequest, VerifyRefundTxSignatureResponse, Messages } from './@types/cfd-dlc-js';
import { Amount, Input, InputDetails, Output, OracleInfo, OfferMessage, AcceptMessage, SignMessage, Contract, PayoutDetails, MutualClosingMessage } from './@types/@atomicfinance/bitcoin-dlc-provider';
import { AddSignaturesToRefundTxRequest, AddSignaturesToRefundTxResponse, AddSignatureToFundTransactionRequest, AddSignatureToFundTransactionResponse, CreateCetAdaptorSignatureRequest, CreateCetAdaptorSignatureResponse, CreateCetAdaptorSignaturesRequest, CreateCetAdaptorSignaturesResponse, CreateCetRequest, CreateCetResponse, CreateDlcTransactionsRequest, CreateDlcTransactionsResponse, CreateFundTransactionRequest, CreateFundTransactionResponse, CreateRefundTransactionRequest, CreateRefundTransactionResponse, GetRawFundTxSignatureRequest, GetRawFundTxSignatureResponse, GetRawRefundTxSignatureRequest, GetRawRefundTxSignatureResponse, SignCetRequest, SignCetResponse, SignFundTransactionRequest, SignFundTransactionResponse, VerifyCetAdaptorSignatureRequest, VerifyCetAdaptorSignatureResponse, VerifyCetAdaptorSignaturesRequest, VerifyCetAdaptorSignaturesResponse, VerifyFundTxSignatureRequest, VerifyFundTxSignatureResponse, VerifyRefundTxSignatureRequest, VerifyRefundTxSignatureResponse } from './@types/cfd-dlc-js';
import { ContractInfo, DlcOffer, DlcAccept, DlcSign, DlcTransactions, OracleAttestationV0 } from '@node-dlc/messaging';
import { Input } from './@types/@atomicfinance/bitcoin-dlc-provider';
import { Psbt } from 'bitcoinjs-lib';
import { Tx } from '@node-dlc/bitcoin';
export default class Dlc {
client: Client;
constructor(client?: Client);
initializeContractAndOffer(input: InputDetails, payouts: PayoutDetails[], oracleInfo: OracleInfo, messagesList: Messages[], startingIndex?: number, fixedInputs?: Input[]): Promise<OfferMessage>;
confirmContractOffer(offerMessage: OfferMessage, startingIndex?: number, fixedInputs?: Input[]): Promise<AcceptMessage>;
signContract(acceptMessage: AcceptMessage): Promise<SignMessage>;
finalizeContract(signMessage: SignMessage): Promise<string>;
refund(contractId: string): Promise<any>;
initiateEarlyExit(contractId: string, outputs: Output[]): Promise<any>;
finalizeEarlyExit(contractId: string, mutualClosingMessage: MutualClosingMessage): Promise<any>;
unilateralClose(outcomeIndex: number, oracleSignatures: string[], contractId: string): Promise<string[]>;
buildUnilateralClose(oracleSignature: string, outcomeIndex: number, contractId: string): Promise<string[]>;
getFundingUtxoAddressesForOfferMessages(offerMessages: OfferMessage[]): Promise<any>;
getFundingUtxoAddressesForAcceptMessages(acceptMessages: AcceptMessage[]): Promise<any>;
hasDlc(contractId: string): boolean;
importContract(contract: Contract, startingIndex: number): Promise<any>;
exportContract(contractId: string): Contract;
exportContracts(): Contract[];
deleteContract(contractId: string): any;
importContractFromOfferMessage(offerMessage: OfferMessage, startingIndex: number): Promise<any>;
importContractFromAcceptMessage(offerMessage: OfferMessage, acceptMessage: AcceptMessage, startingIndex: number): Promise<any>;
importContractFromAcceptAndSignMessage(offerMessage: OfferMessage, acceptMessage: AcceptMessage, signMessage: SignMessage, startingIndex: number): Promise<any>;
importContractFromSignMessageAndCreateFinal(offerMessage: OfferMessage, acceptMessage: AcceptMessage, signMessage: SignMessage, startingIndex?: number): Promise<any>;
outputsToPayouts(outputs: GeneratedOutput[], oracleInfos: OracleInfo[], rValuesMessagesList: Messages[], localCollateral: Amount, remoteCollateral: Amount, payoutLocal: boolean): {
payouts: PayoutDetails[];
messagesList: Messages[];
};
/**
* Create DLC Offer Message
* @param contractInfo ContractInfo TLV (V0 or V1)
* @param offerCollateralSatoshis Amount DLC Initiator is putting into the contract
* @param feeRatePerVb Fee rate in satoshi per virtual byte that both sides use to compute fees in funding tx
* @param cetLocktime The nLockTime to be put on CETs
* @param refundLocktime The nLockTime to be put on the refund transaction
* @returns {Promise<DlcOffer>}
*/
createDlcOffer(contractInfo: ContractInfo, offerCollateralSatoshis: bigint, feeRatePerVb: bigint, cetLocktime: number, refundLocktime: number, fixedInputs?: Input[]): Promise<DlcOffer>;
/**
* Accept DLC Offer
* @param dlcOffer Dlc Offer Message
* @param fixedInputs Optional inputs to use for Funding Inputs
* @returns {Promise<AcceptDlcOfferResponse}
*/
acceptDlcOffer(dlcOffer: DlcOffer, fixedInputs?: Input[]): Promise<AcceptDlcOfferResponse>;
/**
* Sign Dlc Accept Message
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @returns {Promise<SignDlcAcceptResponse}
*/
signDlcAccept(dlcOffer: DlcOffer, dlcAccept: DlcAccept): Promise<SignDlcAcceptResponse>;
/**
* Finalize Dlc Sign
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @param dlcSign Dlc Sign Message
* @param dlcTxs Dlc Transactions Message
* @returns {Promise<Tx>}
*/
finalizeDlcSign(dlcOffer: DlcOffer, dlcAccept: DlcAccept, dlcSign: DlcSign, dlcTxs: DlcTransactions): Promise<Tx>;
/**
* Execute DLC
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @param dlcSign Dlc Sign Message
* @param dlcTxs Dlc Transactions Message
* @param oracleAttestation Oracle Attestations TLV (V0)
* @param isLocalParty Whether party is Dlc Offerer
* @returns {Promise<Tx>}
*/
execute(dlcOffer: DlcOffer, dlcAccept: DlcAccept, dlcSign: DlcSign, dlcTxs: DlcTransactions, oracleAttestation: OracleAttestationV0, isLocalParty: boolean): Promise<Tx>;
/**
* Refund DLC
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @param dlcSign Dlc Sign Message
* @param dlcTxs Dlc Transactions message
* @returns {Promise<Tx>}
*/
refund(dlcOffer: DlcOffer, dlcAccept: DlcAccept, dlcSign: DlcSign, dlcTxs: DlcTransactions): Promise<Tx>;
/**
* Generate PSBT for closing DLC with Mutual Consent
* If no PSBT provided, assume initiator
* If PSBT provided, assume reciprocator
* @param dlcOffer DlcOffer TLV (V0)
* @param dlcAccept DlcAccept TLV (V0)
* @param dlcTxs DlcTransactions TLV (V0)
* @param initiatorPayoutSatoshis Amount initiator expects as a payout
* @param isLocalParty Whether offerer or not
* @param psbt Partially Signed Bitcoin Transaction
* @param inputs Optionally specified closing inputs
* @returns {Promise<Psbt>}
*/
close(dlcOffer: DlcOffer, dlcAccept: DlcAccept, dlcTxs: DlcTransactions, initiatorPayoutSatoshis: bigint, isLocalParty: boolean, psbt?: Psbt, inputs?: Input[]): Promise<Psbt>;
AddSignatureToFundTransaction(jsonObject: AddSignatureToFundTransactionRequest): Promise<AddSignatureToFundTransactionResponse>;

@@ -48,6 +94,9 @@ CreateCetAdaptorSignature(jsonObject: CreateCetAdaptorSignatureRequest): Promise<CreateCetAdaptorSignatureResponse>;

}
interface GeneratedOutput {
payout: number;
groups: number[][];
export interface AcceptDlcOfferResponse {
dlcAccept: DlcAccept;
dlcTransactions: DlcTransactions;
}
export {};
export interface SignDlcAcceptResponse {
dlcSign: DlcSign;
dlcTransactions: DlcTransactions;
}

@@ -7,65 +7,83 @@ "use strict";

}
async initializeContractAndOffer(input, payouts, oracleInfo, messagesList, startingIndex = 0, fixedInputs = []) {
return this.client.getMethod('initializeContractAndOffer')(input, payouts, oracleInfo, messagesList, startingIndex, fixedInputs);
/**
* Create DLC Offer Message
* @param contractInfo ContractInfo TLV (V0 or V1)
* @param offerCollateralSatoshis Amount DLC Initiator is putting into the contract
* @param feeRatePerVb Fee rate in satoshi per virtual byte that both sides use to compute fees in funding tx
* @param cetLocktime The nLockTime to be put on CETs
* @param refundLocktime The nLockTime to be put on the refund transaction
* @returns {Promise<DlcOffer>}
*/
async createDlcOffer(contractInfo, offerCollateralSatoshis, feeRatePerVb, cetLocktime, refundLocktime, fixedInputs) {
return this.client.getMethod('createDlcOffer')(contractInfo, offerCollateralSatoshis, feeRatePerVb, cetLocktime, refundLocktime, fixedInputs);
}
async confirmContractOffer(offerMessage, startingIndex = 0, fixedInputs = []) {
return this.client.getMethod('confirmContractOffer')(offerMessage, startingIndex, fixedInputs);
/**
* Accept DLC Offer
* @param dlcOffer Dlc Offer Message
* @param fixedInputs Optional inputs to use for Funding Inputs
* @returns {Promise<AcceptDlcOfferResponse}
*/
async acceptDlcOffer(dlcOffer, fixedInputs) {
return this.client.getMethod('acceptDlcOffer')(dlcOffer, fixedInputs);
}
async signContract(acceptMessage) {
return this.client.getMethod('signContract')(acceptMessage);
/**
* Sign Dlc Accept Message
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @returns {Promise<SignDlcAcceptResponse}
*/
async signDlcAccept(dlcOffer, dlcAccept) {
return this.client.getMethod('signDlcAccept')(dlcOffer, dlcAccept);
}
async finalizeContract(signMessage) {
return this.client.getMethod('finalizeContract')(signMessage);
/**
* Finalize Dlc Sign
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @param dlcSign Dlc Sign Message
* @param dlcTxs Dlc Transactions Message
* @returns {Promise<Tx>}
*/
async finalizeDlcSign(dlcOffer, dlcAccept, dlcSign, dlcTxs) {
return this.client.getMethod('finalizeDlcSign')(dlcOffer, dlcAccept, dlcSign, dlcTxs);
}
async refund(contractId) {
return this.client.getMethod('refund')(contractId);
/**
* Execute DLC
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @param dlcSign Dlc Sign Message
* @param dlcTxs Dlc Transactions Message
* @param oracleAttestation Oracle Attestations TLV (V0)
* @param isLocalParty Whether party is Dlc Offerer
* @returns {Promise<Tx>}
*/
async execute(dlcOffer, dlcAccept, dlcSign, dlcTxs, oracleAttestation, isLocalParty) {
return this.client.getMethod('execute')(dlcOffer, dlcAccept, dlcSign, dlcTxs, oracleAttestation, isLocalParty);
}
async initiateEarlyExit(contractId, outputs) {
return this.client.getMethod('initiateEarlyExit')(contractId, outputs);
/**
* Refund DLC
* @param dlcOffer Dlc Offer Message
* @param dlcAccept Dlc Accept Message
* @param dlcSign Dlc Sign Message
* @param dlcTxs Dlc Transactions message
* @returns {Promise<Tx>}
*/
async refund(dlcOffer, dlcAccept, dlcSign, dlcTxs) {
return this.client.getMethod('refund')(dlcOffer, dlcAccept, dlcSign, dlcTxs);
}
async finalizeEarlyExit(contractId, mutualClosingMessage) {
return this.client.getMethod('finalizeEarlyExit')(contractId, mutualClosingMessage);
/**
* Generate PSBT for closing DLC with Mutual Consent
* If no PSBT provided, assume initiator
* If PSBT provided, assume reciprocator
* @param dlcOffer DlcOffer TLV (V0)
* @param dlcAccept DlcAccept TLV (V0)
* @param dlcTxs DlcTransactions TLV (V0)
* @param initiatorPayoutSatoshis Amount initiator expects as a payout
* @param isLocalParty Whether offerer or not
* @param psbt Partially Signed Bitcoin Transaction
* @param inputs Optionally specified closing inputs
* @returns {Promise<Psbt>}
*/
async close(dlcOffer, dlcAccept, dlcTxs, initiatorPayoutSatoshis, isLocalParty, psbt, inputs) {
return this.client.getMethod('close')(dlcOffer, dlcAccept, dlcTxs, initiatorPayoutSatoshis, isLocalParty, psbt, inputs);
}
async unilateralClose(outcomeIndex, oracleSignatures, contractId) {
return this.client.getMethod('unilateralClose')(outcomeIndex, oracleSignatures, contractId);
}
async buildUnilateralClose(oracleSignature, outcomeIndex, contractId) {
return this.client.getMethod('buildUnilateralClose')(oracleSignature, outcomeIndex, contractId);
}
async getFundingUtxoAddressesForOfferMessages(offerMessages) {
return this.client.getMethod('getFundingUtxoAddressesForOfferMessages')(offerMessages);
}
async getFundingUtxoAddressesForAcceptMessages(acceptMessages) {
return this.client.getMethod('getFundingUtxoAddressesForAcceptMessages')(acceptMessages);
}
hasDlc(contractId) {
return this.client.getMethod('hasDlc')(contractId);
}
async importContract(contract, startingIndex) {
return this.client.getMethod('importContract')(contract, startingIndex);
}
exportContract(contractId) {
return this.client.getMethod('exportContract')(contractId);
}
exportContracts() {
return this.client.getMethod('exportContracts')();
}
deleteContract(contractId) {
return this.client.getMethod('deleteContract')(contractId);
}
async importContractFromOfferMessage(offerMessage, startingIndex) {
return this.client.getMethod('importContractFromOfferMessage')(offerMessage, startingIndex);
}
async importContractFromAcceptMessage(offerMessage, acceptMessage, startingIndex) {
return this.client.getMethod('importContractFromAcceptMessage')(offerMessage, acceptMessage, startingIndex);
}
async importContractFromAcceptAndSignMessage(offerMessage, acceptMessage, signMessage, startingIndex) {
return this.client.getMethod('importContractFromAcceptAndSignMessage')(offerMessage, acceptMessage, signMessage, startingIndex);
}
async importContractFromSignMessageAndCreateFinal(offerMessage, acceptMessage, signMessage, startingIndex = 0) {
return this.client.getMethod('importContractFromSignMessageAndCreateFinal')(offerMessage, acceptMessage, signMessage, startingIndex);
}
outputsToPayouts(outputs, oracleInfos, rValuesMessagesList, localCollateral, remoteCollateral, payoutLocal) {
return this.client.getMethod('outputsToPayouts')(outputs, oracleInfos, rValuesMessagesList, localCollateral, remoteCollateral, payoutLocal);
}
async AddSignatureToFundTransaction(jsonObject) {

@@ -72,0 +90,0 @@ return this.client.getMethod('AddSignatureToFundTransaction')(jsonObject);

{
"name": "@atomicfinance/client",
"umdName": "Client",
"version": "1.0.0",
"description": "> TODO: description",
"author": "Matthew Black <mblackmblackmblack@gmail.com>",
"version": "2.0.0-alpha.0",
"description": "CAL Finance Client Provider",
"author": "Atomic Finance <info@atomic.finance>",
"homepage": "",

@@ -23,2 +23,4 @@ "license": "ISC",

"@liquality/errors": "^0.7.1",
"@node-dlc/bitcoin": "0.1.0",
"@node-dlc/messaging": "0.1.0",
"lodash": "^4.17.20"

@@ -32,3 +34,3 @@ },

},
"gitHead": "3040814c31dd62ede1bbf9bb6d20637019477a23"
"gitHead": "4ec4615b25db18d265828d6e90936e415508a4ee"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc