mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-22 10:43:26 +00:00
architecture
This commit is contained in:
20
docs/TapTrade_obs/.obsidian/workspace.json
vendored
20
docs/TapTrade_obs/.obsidian/workspace.json
vendored
@ -13,11 +13,11 @@
|
||||
"state": {
|
||||
"type": "canvas",
|
||||
"state": {
|
||||
"file": "Research/Trade Pipelines/new concepts/concept pipeline 1.canvas",
|
||||
"file": "Research/Implementation/CLI demonstrator architecture/demonstrator architecture.canvas",
|
||||
"viewState": {
|
||||
"x": 200.29145596293188,
|
||||
"y": 1110.762218345142,
|
||||
"zoom": -0.5681202822884297
|
||||
"x": -18.47779088477204,
|
||||
"y": -102.56510451238792,
|
||||
"zoom": -0.23504842122395792
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Research/Trade Pipelines/new concepts/concept pipeline 1.canvas",
|
||||
"file": "Research/Implementation/CLI demonstrator architecture/demonstrator architecture.canvas",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
@ -105,7 +105,7 @@
|
||||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"file": "Research/Trade Pipelines/new concepts/concept pipeline 1.canvas",
|
||||
"file": "Research/Implementation/CLI demonstrator architecture/demonstrator architecture.canvas",
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
}
|
||||
@ -128,7 +128,7 @@
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Research/Trade Pipelines/new concepts/concept pipeline 1.canvas"
|
||||
"file": "Research/Implementation/CLI demonstrator architecture/demonstrator architecture.canvas"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,9 +151,11 @@
|
||||
},
|
||||
"active": "bdb9fd88a01a8909",
|
||||
"lastOpenFiles": [
|
||||
"Research/Trade Pipelines/current trade flow.canvas",
|
||||
"Research/Trade Pipelines/new concepts/concept locking script 1.canvas",
|
||||
"Research/Trade Pipelines/new concepts/concept pipeline 1.canvas",
|
||||
"Research/Implementation/CLI demonstrator architecture/demonstrator architecture.canvas",
|
||||
"Research/Implementation/CLI demonstrator architecture",
|
||||
"Research/Trade Pipelines/new concepts/concept locking script 1.canvas",
|
||||
"Research/Trade Pipelines/current trade flow.canvas",
|
||||
"Research/Trade Pipelines/new concepts/Untitled.md",
|
||||
"Research/Bitcoin fundamentals/Taproot output structure.canvas",
|
||||
"Research/Bitcoin fundamentals/Spending Taproot UTXOs.md",
|
||||
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"nodes":[
|
||||
{"id":"deac0e8159d44e7f","x":300,"y":-170,"width":250,"height":80,"type":"text","text":"Trading only logic"},
|
||||
{"id":"fa909bd36f010298","x":-400,"y":-600,"width":250,"height":60,"type":"text","text":"CLI input parsing"},
|
||||
{"id":"66a07a00114aaee3","x":-1060,"y":-160,"width":250,"height":60,"type":"text","text":"Coordination only logic"},
|
||||
{"id":"190c13d27acfe062","x":-740,"y":-160,"width":220,"height":60,"color":"2","type":"text","text":"Coordinator module"},
|
||||
{"id":"3090e35b6908a516","x":0,"y":-160,"width":250,"height":60,"color":"4","type":"text","text":"Trader module"},
|
||||
{"id":"5d7f46a9378f9d00","x":-380,"y":-235,"width":250,"height":150,"type":"text","text":"Shared logic\nblockchain scanning,\nBDK functions"},
|
||||
{"id":"a42a47db35e79b8a","x":-380,"y":160,"width":250,"height":200,"type":"text","text":"Communication module\n\nModule to exchange messages between Coordinator and Trader. Possibly http requests over Tor"},
|
||||
{"id":"71bd23cde637dcfa","x":-455,"y":-780,"width":360,"height":120,"color":"6","type":"text","text":"**How we could split the code into different parts** to keep the trader module as lightweight as possible"},
|
||||
{"id":"9d377d1901605378","x":-80,"y":-820,"width":280,"height":160,"type":"text","text":"We should prevent hardcoding a specific trade contract as far as possible to make changes easier"}
|
||||
],
|
||||
"edges":[
|
||||
{"id":"0a9f63d0d4d620de","fromNode":"3090e35b6908a516","fromSide":"bottom","toNode":"a42a47db35e79b8a","toSide":"top"},
|
||||
{"id":"ed2f5444cd6d2e87","fromNode":"190c13d27acfe062","fromSide":"bottom","toNode":"a42a47db35e79b8a","toSide":"top"},
|
||||
{"id":"ef6dbff0181ef315","fromNode":"fa909bd36f010298","fromSide":"bottom","toNode":"3090e35b6908a516","toSide":"top"},
|
||||
{"id":"1c0ad74a3e07f73d","fromNode":"fa909bd36f010298","fromSide":"bottom","toNode":"190c13d27acfe062","toSide":"top"},
|
||||
{"id":"523c400735298a49","fromNode":"deac0e8159d44e7f","fromSide":"left","toNode":"3090e35b6908a516","toSide":"right"},
|
||||
{"id":"c095e026270628b6","fromNode":"66a07a00114aaee3","fromSide":"right","toNode":"190c13d27acfe062","toSide":"left"},
|
||||
{"id":"dd546164c04d757c","fromNode":"5d7f46a9378f9d00","fromSide":"right","toNode":"3090e35b6908a516","toSide":"left"},
|
||||
{"id":"5b25907153b1f3f8","fromNode":"5d7f46a9378f9d00","fromSide":"left","toNode":"190c13d27acfe062","toSide":"right"}
|
||||
]
|
||||
}
|
@ -4,12 +4,12 @@
|
||||
{"id":"9945f983ca9b2b3c","type":"text","text":"MSTB Escrow locking key\n(External key of taproot contract where trade participants lock their money to)","x":-678,"y":-690,"width":260,"height":160},
|
||||
{"id":"4f4cec183e99cc39","type":"text","text":"Internal Key\nSigned by Taker, Maker and Coordinator via MuSig2 in case of complete trade\n","x":-1025,"y":-490,"width":287,"height":140},
|
||||
{"id":"3584cf3a74895521","type":"text","text":"Script A\n\nAND(AND(TIMELOCK(escrow timer), SIG(MAKER)), SIG(COORDINATOR))\n\nTimeout if Taker doesn't respond anymore.\n\nEverything to Maker\n\n`and_v(v:pk(COORDINATOR),and_v(v:pk(MAKER),after(144)))`","x":-401,"y":-490,"width":278,"height":340},
|
||||
{"id":"cd16e3e9eda3242d","type":"text","text":"(Script B)\nCould also be keyspend MuSig2 spend!\n\nMUSIG(SIG(Maker) && SIG(Taker) && SIG(COORDINATOR))\n\n`and_v(v:pk(MAKER),and_v(v:pk(TAKER),pk(COORDINATOR)))`\n\nEscrow + Maker Bond to Maker.\n\nTaker Bond to Taker\n\nNeeds Coordinator signature to prevent Maker and Taker from stealing Fees of coordinator after successful trade.","x":-88,"y":-490,"width":250,"height":560},
|
||||
{"id":"1ae1e95c01b93a8d","type":"text","text":"Script E\nAND(TIMELOCK(**Very** long timelock) & SIG(Maker))\n\n`and_v(v:pk(MAKER),after(12228))`\n\neverything to Maker\n\nbackup in case coordinator and Taker is gone.\nTimelock has to be longer than maximum escrow period. Timelock needs to be very long to incentivise cosigning with coordinator in Script C to get Fees to coordinator.\n\nAlso as protection against extortion trough Coordinator (aka. hey i help you in your dipute but it will cost 90% fees)","x":-404,"y":-130,"width":285,"height":580},
|
||||
{"id":"38bc9592ec0c29e2","type":"text","text":"SCRIPT F\nAND(TIMELOCK(2048), AND(SIG(TAKER), SIG(MAKER)))\n`and_v(and_v(v:pk(MAKER),v:pk(TAKER)),after(2048))`\n\nCooperative close without coordinator, in case coordinator vanishes or doesn't cosign.\n\nCould be used to prevent paying fees to coordinator after successful trade but both maker and taker would have to cooperate and wait at least some time.\n\nIf coordinator is offline this would need a direct communication layer between maker and taker to create the transaction, realistic? \n\n","x":-88,"y":110,"width":250,"height":720},
|
||||
{"id":"c7d1840bae375d47","type":"text","text":"Check size, op_checksigadd 2of2 vs just checking 2 sigs. Maybe there is optimization possible.","x":-399,"y":550,"width":280,"height":130,"color":"1"},
|
||||
{"id":"f5fbfebcea40c384","type":"text","text":"SCRIPT C\n\nAND(SIG(Maker), SIG(COORDINATOR))\n`and_v(v:pk(MAKER),pk(COORDINATOR))`\n\nFees to coordinator.\nRemaining to Maker\n\n","x":179,"y":-490,"width":385,"height":200},
|
||||
{"id":"341d50e0a5929e24","type":"text","text":"Script D\n\nAND(SIG(TAKER), SIG(COORDINATOR))\n`and_v(v:pk(TAKER),pk(COORDINATOR))`\n\nFees to coordinator.\nRemaining to Taker.","x":579,"y":-490,"width":447,"height":200}
|
||||
{"id":"c7d1840bae375d47","type":"text","text":"Check size, op_checksigadd 2of2 vs just checking 2 sigs. Maybe there is optimization possible.","x":140,"y":-770,"width":280,"height":130,"color":"1"},
|
||||
{"id":"cd16e3e9eda3242d","type":"text","text":"(Script B)\nCould also be keyspend MuSig2 spend!\n\nMUSIG(SIG(Maker) && SIG(Taker) && SIG(COORDINATOR))\n\n`and_v(v:pk(MAKER),and_v(v:pk(TAKER),pk(COORDINATOR)))`\n\nEscrow + Maker Bond to Maker.\n\nTaker Bond to Taker\n\nNeeds Coordinator signature to prevent Maker and Taker from stealing Fees of coordinator after successful trade.","x":-110,"y":-490,"width":250,"height":560},
|
||||
{"id":"f5fbfebcea40c384","type":"text","text":"SCRIPT C\n\nAND(SIG(Maker), SIG(COORDINATOR))\n`and_v(v:pk(MAKER),pk(COORDINATOR))`\n\nFees to coordinator.\nRemaining to Maker\n\n","x":227,"y":-490,"width":385,"height":200},
|
||||
{"id":"341d50e0a5929e24","type":"text","text":"Script D\n\nAND(SIG(TAKER), SIG(COORDINATOR))\n`and_v(v:pk(TAKER),pk(COORDINATOR))`\n\nFees to coordinator.\nRemaining to Taker.","x":640,"y":-490,"width":447,"height":200},
|
||||
{"id":"1ae1e95c01b93a8d","type":"text","text":"Script E\nAND(TIMELOCK(**Very** long timelock) & SIG(Maker))\n\n`and_v(v:pk(MAKER),after(12228))`\n\neverything to Maker\n\nbackup in case coordinator and Taker is gone.\nTimelock has to be longer than maximum escrow period. Timelock needs to be very long to incentivise cosigning with coordinator in Script C to get Fees to coordinator.\n\nAlso as protection against extortion trough Coordinator (aka. hey i help you in your dipute but it will cost 90% fees)","x":-418,"y":120,"width":285,"height":580},
|
||||
{"id":"38bc9592ec0c29e2","type":"text","text":"SCRIPT F\nAND(TIMELOCK(2048), AND(SIG(TAKER), SIG(MAKER)))\n`and_v(and_v(v:pk(MAKER),v:pk(TAKER)),after(2048))`\n\nCooperative close without coordinator, in case coordinator vanishes or doesn't cosign.\n\nCould be used to prevent paying fees to coordinator after successful trade but both maker and taker would have to cooperate and wait at least some time.\n\nIf coordinator is offline this would need a direct communication layer between maker and taker to create the transaction, realistic? \n\n","x":-91,"y":120,"width":250,"height":720}
|
||||
],
|
||||
"edges":[
|
||||
{"id":"28e9d5ed421b6360","fromNode":"4f4cec183e99cc39","fromSide":"top","toNode":"9945f983ca9b2b3c","toSide":"left"},
|
||||
|
@ -3,24 +3,24 @@
|
||||
{"id":"5b8863761f608702","type":"text","text":"Just going to write some stuff down here while thinking about it. **Don't expect it to make sense yet!**","x":-415,"y":-360,"width":460,"height":80,"color":"1"},
|
||||
{"id":"8b7862709255b800","type":"text","text":"\n***MSTB*** (Maker seller taker buyer)","x":-345,"y":-440,"width":320,"height":60,"color":"3"},
|
||||
{"id":"428c2dc0767db819","type":"text","text":"semi trusted - coordinator could steal/burn bond - but low risk as bonds are small and reputation would be damaged. Also no control on full trade amount.","x":-402,"y":-260,"width":434,"height":118,"color":"5"},
|
||||
{"id":"93c73227c82f1a81","type":"text","text":"**Coordinator**\n\nwatches Mempool and Chain, could publish the bond TX. Essentially just to prevent orderbook spam / for skin in the game.\n\n*SIGHASH_ALL | ANYONECANPAY* could make it possible for the coordinator to add inputs up to the height of the bond to push the TX fees without losing capital itself. \nAlso out of band mining would cause a cost for the Maker so there is always a price to being unreliable. \n\nThe Maker could be required to use Inputs at least the value of the trade amount to proof that he owns enough sats to fulfill the trade.","x":80,"y":-118,"width":500,"height":388},
|
||||
{"id":"93c73227c82f1a81","type":"text","text":"**Coordinator**\n\nwatches Mempool and Chain, could publish the bond TX. Essentially just to prevent orderbook spam / for skin in the game.\n\n*SIGHASH_ALL | ANYONECANPAY* could make it possible for the coordinator to add inputs up to the height of the bond to push the TX fees without losing capital itself. \nAlso out of band mining would cause a cost for the Maker so there is always a price to being unreliable. \n\nThe Maker could be required to use Inputs at least the value of the trade amount to proof that he owns enough sats to fulfill the trade. Maybe lock the time to invalidate the bond after a certain amount of time.","x":80,"y":-118,"width":500,"height":388},
|
||||
{"id":"dba9c662192cf5bb","type":"text","text":"**Maker**","x":-600,"y":47,"width":125,"height":58},
|
||||
{"id":"4a633210842ee3c0","type":"text","text":"Taker","x":-665,"y":410,"width":250,"height":60},
|
||||
{"id":"f461d9afa4298d14","type":"text","text":"Coordinator","x":135,"y":410,"width":250,"height":60},
|
||||
{"id":"f1c3087260abe818","type":"text","text":"+ payout address\n+ MuSig2 public nonce\n+ taproot public key (for agg. internal key)\n+ Bond input reference","x":-275,"y":320,"width":250,"height":240},
|
||||
{"id":"f1c3087260abe818","type":"text","text":"+ payout address\n+ MuSig2 public nonce\n+ taproot public key (for agg. internal key)\n+ Bond input reference","x":-275,"y":320,"width":250,"height":260},
|
||||
{"id":"bdce49ceea829893","type":"text","text":"Taker","x":-652,"y":690,"width":192,"height":60},
|
||||
{"id":"961e75c701b7f68f","type":"text","text":"Coordinator","x":80,"y":690,"width":250,"height":60},
|
||||
{"id":"73a7dae830df4443","type":"text","text":"PSBT of contract\nTaker adds bond input sig","x":-320,"y":660,"width":250,"height":120},
|
||||
{"id":"90704c232582cd52","type":"text","text":"Coordinator","x":80,"y":940,"width":250,"height":60},
|
||||
{"id":"b500fab6ba26abf1","type":"text","text":"Maker","x":-665,"y":1120,"width":250,"height":60},
|
||||
{"id":"9b054e655a321517","type":"text","text":"PSBT of contract\nMaker adds escrow input sig","x":-320,"y":1010,"width":250,"height":110},
|
||||
{"id":"de1642ddfdfed1df","type":"text","text":"Coordinator \npublishes contract TX and waits for confirmation","x":80,"y":1180,"width":250,"height":120,"color":"2"},
|
||||
{"id":"910e5a3ee7688d0b","type":"text","text":"Escrow and Bond locked in contract.\n**Chat can begin**","x":-300,"y":1380,"width":250,"height":120,"color":"6"},
|
||||
{"id":"880c77a2d23f2cec","type":"text","text":"+signed TX\n\n-> Bond to coordinator\n -> change to self\n -> SIGHASH_ALL | ANYONECANPAY\n\n+MuSig2 public nonce\n+taproot public key (for agg. internal key)","x":-390,"y":-39,"width":390,"height":230},
|
||||
{"id":"e3b8669b30d1c80e","type":"text","text":"+ signed psbt\n+ signed punishment TX in case the taker tries to spend the input somewhere else before the maker signs, the coordinator can claim or burn the bond (same like the maker bond). In case of out of band mining the maker would not lose money and the taker has a cost associated to doing this act","x":-610,"y":800,"width":815,"height":120},
|
||||
{"id":"483fbdbcc5ea8501","type":"text","text":"I think there could be an advanced mode / external wallet mode where this could be done directly from an external Wallet e.g. Hardware wallet with Sparrow. But it would require lot of copy pasting (signed txs, psbts, addresses). Also there is secret state needed to be saved for MuSig2, this could be downloaded as file or stored encrypted on the coordinator. \n\nFor easy use there would need to be a wallet in RoboSats (BDK) but UI wise this would be either a challenge or a privacy reduction (if you use the same wallet but different Robot). It's also possible to limit the Wallet to one robot so the user must withdraw the sats after the trade (can't import wallet into robosats, only export). I think wallet could also be stored encrypted on coordinator or exported as file/seed.","x":80,"y":-480,"width":660,"height":338},
|
||||
{"id":"51e650a981068490","type":"text","text":"see contract definition","x":420,"y":1120,"width":400,"height":60,"color":"2"},
|
||||
{"id":"0d1d6b982cbde6e2","x":420,"y":1180,"width":400,"height":400,"type":"file","file":"Research/Trade Pipelines/new concepts/concept locking script 1.canvas"}
|
||||
{"id":"e3b8669b30d1c80e","type":"text","text":"+ signed psbt\n+ additional signed punishment TX in case the taker tries to spend the input somewhere else before the maker signs, the coordinator can claim or burn the bond (same like the maker bond). In case of out of band mining the maker would not lose money and the taker has a cost associated to doing this act","x":-610,"y":800,"width":815,"height":140},
|
||||
{"id":"90704c232582cd52","type":"text","text":"Coordinator","x":80,"y":950,"width":250,"height":60},
|
||||
{"id":"0d1d6b982cbde6e2","type":"file","file":"Research/Trade Pipelines/new concepts/concept locking script 1.canvas","x":420,"y":1220,"width":400,"height":400}
|
||||
],
|
||||
"edges":[
|
||||
{"id":"77d1ff9130716b53","fromNode":"dba9c662192cf5bb","fromSide":"right","toNode":"93c73227c82f1a81","toSide":"left"},
|
||||
|
Reference in New Issue
Block a user