Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6451bb4
Use deterministic key channel path for LOCAL -> REMOTE channel opening
araspitzu May 21, 2019
6c3c306
Factor out function to compute the deterministic keypath from the fun…
araspitzu May 21, 2019
9436c78
WIP funder channel opening flow
araspitzu May 29, 2019
3fd125e
WIP funder channel opening flow
araspitzu May 31, 2019
9992581
Remove unnecessary logs
araspitzu May 31, 2019
2235c6f
Use different states/events to handle creation/signing of the funding tx
araspitzu Jun 3, 2019
0810f12
Fix test for internal funding created state
araspitzu Jun 3, 2019
54a0e59
Revert changes to use old derivation path for REMOTE -> LOCAL
araspitzu Jun 3, 2019
f77e1f8
Use bech32 test address
araspitzu Jun 4, 2019
132035b
Use deterministic derivation
araspitzu Jun 5, 2019
3980fa0
Bump commitment version for scodecs
araspitzu Jun 5, 2019
2a329d6
Sort scodecs properly, update test
araspitzu Jun 5, 2019
3b25ea5
Use new derivation scheme for fundee scenario
araspitzu Jun 5, 2019
b041d94
Add test vectors for key derivation
araspitzu Jun 6, 2019
596bc0c
Store counter on channelDb
araspitzu Jun 7, 2019
004a2a6
Update test vectors
araspitzu Jun 7, 2019
92ee96c
Do not use hardened index for shaSeed and test the shaSeed public poi…
araspitzu Jun 7, 2019
64f4b33
Add test for fundee/funder keypath choice
araspitzu Jun 7, 2019
3da0894
Add test to electrum wallet for SignTransactionResponse
araspitzu Jun 11, 2019
a3db46f
Use dummy script in MakeFundingTx
araspitzu Jun 11, 2019
169c1b3
Add test for WAIT_FOR_FUNDING_CREATED_INTERNAL
araspitzu Jun 12, 2019
a4f32f9
Remove empty lines
araspitzu Jun 12, 2019
726c5d9
Rollback funding tx if the flow is aborted in state WAIT_FOR_ACCEPT_C…
araspitzu Jun 12, 2019
5ded959
Remove unused functions
araspitzu Jun 12, 2019
9e4db87
Fix race condition in flaky test WaitForFundingCreatedInternalStateSpec
araspitzu Jun 12, 2019
12caee2
KeyManager cleanup from deterministic* methods
araspitzu Jun 14, 2019
847eb06
Upgrade localParams scodec to handle previous version fundee scenario,
araspitzu Jun 14, 2019
debd6a1
Rollback fundingTx if there is an error when waiting for the signatur…
araspitzu Jun 14, 2019
7770a58
Use SubscribeTransitionCallBack to correctly wait for states during test
araspitzu Jun 14, 2019
c1a976d
Merge branch 'master' into deterministic_channel_keypath
araspitzu Jun 14, 2019
53b3bee
Merge branch 'master' into deterministic_channel_keypath
araspitzu Jun 17, 2019
f78f2f3
Finish merging master
araspitzu Jun 17, 2019
0d5d15d
Do not alter root derivation paths from previous eclair's version, up…
araspitzu Jun 17, 2019
602e73b
Use hardened BIP32 indexes also for the the internal keypaths
araspitzu Jun 17, 2019
922072f
Remove unnecessary println, merge master, improve handling of rollbac…
araspitzu Jun 18, 2019
79a8284
Wait for correct state in test
araspitzu Jun 18, 2019
a693df5
Use a non returing call to avoid quick transition during test
araspitzu Jun 18, 2019
4b24e03
Add counter table to migration v1 -> v2
araspitzu Jun 18, 2019
f95bd00
Test backward compatibility for state transition WAIT_FOR_FUNDING_CON…
araspitzu Jun 24, 2019
08395e8
Test backward compatibility for state transition WAIT_FOR_FUNDING_LOC…
araspitzu Jun 24, 2019
8a3cd4a
Merge branch 'master' into deterministic_channel_keypath
araspitzu Jun 25, 2019
518947a
Merge branch 'master' into deterministic_channel_keypath
araspitzu Jul 4, 2019
bdcd0ab
Finish merging master
araspitzu Jul 4, 2019
259748b
Renaming
araspitzu Jul 4, 2019
5c1698e
Move the publishing of `ChannelCreated` close to the sending of `open…
araspitzu Jul 4, 2019
49355a1
Merge branch 'master' into deterministic_channel_keypath
araspitzu Jul 15, 2019
f26791e
Merge branch 'master' into deterministic_channel_keypath
araspitzu Jul 15, 2019
6136adf
Use transitions callbacks to avoid race condition in test
araspitzu Jul 16, 2019
2b00b14
Do not send message to remote (bob) during fixture setup
araspitzu Jul 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ trait EclairWallet {

def getFinalAddress: Future[String]

def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: Long): Future[MakeFundingTxResponse]
def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: Long, lockUnspent: Boolean = true): Future[MakeFundingTxResponse]

def signTransactionComplete(tx: Transaction): Future[Transaction]

/**
* Committing *must* include publishing the transaction on the network.
Expand Down Expand Up @@ -67,3 +69,4 @@ trait EclairWallet {
}

final case class MakeFundingTxResponse(fundingTx: Transaction, fundingTxOutputIndex: Int, fee: Satoshi)
final case class SignFundingTxResponse(fundingTx: Transaction, fundingTxOutputIndex: Int, fee: Satoshi)
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class BitcoinCoreWallet(rpcClient: BitcoinJsonRPCClient)(implicit ec: ExecutionC

def signTransaction(tx: Transaction): Future[SignTransactionResponse] = signTransaction(Transaction.write(tx).toHex)

override def signTransactionComplete(tx: Transaction): Future[Transaction] = signTransaction(tx).map {
case SignTransactionResponse(signedTx, true) => signedTx
case _ => throw new IllegalStateException("Signed transaction is not complete")
}

def getTransaction(txid: ByteVector32): Future[Transaction] = rpcClient.invoke("getrawtransaction", txid.toString()) collect { case JString(hex) => Transaction.read(hex) }

def publishTransaction(tx: Transaction)(implicit ec: ExecutionContext): Future[String] = publishTransaction(Transaction.write(tx).toHex)
Expand Down Expand Up @@ -89,7 +94,7 @@ class BitcoinCoreWallet(rpcClient: BitcoinJsonRPCClient)(implicit ec: ExecutionC
}
}

override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: Long): Future[MakeFundingTxResponse] = {
override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: Long, lockUnspent: Boolean = true): Future[MakeFundingTxResponse] = {
// partial funding tx
val partialFundingTx = Transaction(
version = 2,
Expand All @@ -98,7 +103,7 @@ class BitcoinCoreWallet(rpcClient: BitcoinJsonRPCClient)(implicit ec: ExecutionC
lockTime = 0)
for {
// we ask bitcoin core to add inputs to the funding tx, and use the specified change address
FundTransactionResponse(unsignedFundingTx, _, fee) <- fundTransaction(partialFundingTx, lockUnspents = true, feeRatePerKw)
FundTransactionResponse(unsignedFundingTx, _, fee) <- fundTransaction(partialFundingTx, lockUnspents = lockUnspent, feeRatePerKw)
// now let's sign the funding tx
SignTransactionResponse(fundingTx, true) <- signTransactionOrUnlock(unsignedFundingTx)
// there will probably be a change output, so we need to find which output is ours
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class ElectrumEclairWallet(val wallet: ActorRef, chainHash: ByteVector32)(implic

def getXpub: Future[GetXpubResponse] = (wallet ? GetXpub).mapTo[GetXpubResponse]

override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: Long): Future[MakeFundingTxResponse] = {
override def signTransactionComplete(tx: Transaction): Future[Transaction] = {
(wallet ? SignTransaction(tx)).mapTo[SignTransactionResponse].map(_.tx)
}

override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: Long, lockUnspent: Boolean = true): Future[MakeFundingTxResponse] = {
val tx = Transaction(version = 2, txIn = Nil, txOut = TxOut(amount, pubkeyScript) :: Nil, lockTime = 0)
(wallet ? CompleteTransaction(tx, feeRatePerKw)).mapTo[CompleteTransactionResponse].map(response => response match {
case CompleteTransactionResponse(tx1, fee1, None) => MakeFundingTxResponse(tx1, 0, fee1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ class ElectrumWallet(seed: ByteVector, client: ActorRef, params: ElectrumWallet.
log.info(s"cancelling txid=${tx.txid}")
stay using persistAndNotify(data.cancelTransaction(tx)) replying CancelTransactionResponse(tx)

case Event(SignTransaction(tx), data) =>
log.info(s"signing txid=${tx.txid}")
val signed = data.signTransaction(tx)
stay replying SignTransactionResponse(signed)

case Event(bc@ElectrumClient.BroadcastTransaction(tx), _) =>
log.info(s"broadcasting txid=${tx.txid}")
client forward bc
Expand Down Expand Up @@ -543,6 +548,9 @@ object ElectrumWallet {
case class IsDoubleSpent(tx: Transaction) extends Request
case class IsDoubleSpentResponse(tx: Transaction, isDoubleSpent: Boolean) extends Response

case class SignTransaction(tx: Transaction) extends Request
case class SignTransactionResponse(tx: Transaction) extends Response

sealed trait WalletEvent
/**
*
Expand Down
Loading