Adding /close api endpoint to allow closing a payment channel.
Description
The endpoint accept POST method. The json message should have a field redeemScript with the matching redeem script of the payment channel we wish to close.
While the script is only known by the 2 people who creating the payment channel it can be recreated by knowing the public keys. Public keys being public it is likely possible. A better way of authentication should be proposed.
The payment channel can be in different states :
Announced : meaning /announced was called but the transaction hasn't been seen yet on the chain. In this case we should return an error when trying to close this.
Opened : the opening transaction has been seen on the chain and confirmed. We should attempt to sign and brodacast a transaction if we have already saved in the database a micro payment. We can have the case where no micro transaction has been done and we can't close the payment channel without asking the payer (Alice) to sign one. We could fix this by having the payer (Alice) to provide us with one at the /announce step.
Closed : payment channel already closed. Return an error.
Abstract
Adding
/close
api endpoint to allow closing a payment channel.Description
The endpoint accept
POST
method. The json message should have a fieldredeemScript
with the matching redeem script of the payment channel we wish to close.While the script is only known by the 2 people who creating the payment channel it can be recreated by knowing the public keys. Public keys being public it is likely possible. A better way of authentication should be proposed.
The payment channel can be in different states :
Announced
: meaning/announced
was called but the transaction hasn't been seen yet on the chain. In this case we should return an error when trying to close this.Opened
: the opening transaction has been seen on the chain and confirmed. We should attempt to sign and brodacast a transaction if we have already saved in the database a micro payment. We can have the case where no micro transaction has been done and we can't close the payment channel without asking the payer (Alice) to sign one. We could fix this by having the payer (Alice) to provide us with one at the/announce
step.Closed
: payment channel already closed. Return an error.TODO
/close
endpointAnnounced
Closed
/announce
call