Created
July 1, 2016 09:25
-
-
Save runeksvendsen/3ab5e2a933e90979a0680c71fc6583e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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