Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save runeksvendsen/3ab5e2a933e90979a0680c71fc6583e6 to your computer and use it in GitHub Desktop.
Save runeksvendsen/3ab5e2a933e90979a0680c71fc6583e6 to your computer and use it in GitHub Desktop.
var chanState = new PaymentChannel(serverURL, ecKeyPair, expirationUnixTimestamp);
chanState.getFundingInfo(function (fundingAddress, openPrice, fundingTxMinConf) {
// pay to 'fundingAddress' here
// wait for 'fundingTxMinConf' confirmations before proceeding to open step
});
var fi = blockchain_GetTxInfoFromAddress(fundingAddress) // get information about the transaction paying to the funding address
chanState.setFundingSource( fi.txid, fi.vout, fi.value ); // register this information with the state object
var refundAddress = "1MmWtRnvdayQqVaRdpnsGNesCch7eptZnP";
var txHexStr = chanState.getRefundTx(refundAddress, fee).toHex(); //(optional) create a refund transaction
chanState.openChannel(refundAddress, function (payConn, payInfo) {
// make payments using the payConn object:
payConn.makePayment(100, callback);
payConn.makePayment(1, callback);
payConn.makePayment(47, callback);
payConn.makePayment(32, callback);
payConn.deleteChannel(callback);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment