0

Currently our site works with "stripe marketplace" and we trying to also implement bitcoins.

I would like to know that Bitcoins API can give me a split payment service?

For example: From buyer to seller and to us (3%) all at once. All instant without holding money.

Any alternatives?

2

1 Answer 1

1

Alice is buyer, Bob is seller and Carol manages the marketplace in this example.

bitcoin-cli createwallet "W1"
{
  "name": "W1",
  "warning": ""
}

bitcoin-cli createwallet "W2"
{
  "name": "W2",
  "warning": ""
}

Alice(W1) and Bob(W2) update their public keys in the marketplace for an order:

"address": "tb1qadr842f467n2hdvg579knxn396jlvq2q6as6d4" (Alice)

"pubkey": "03217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a39"


"address": "tb1q3ykxvwdaf9ddue9m8zsgxw4p6lev438djdayly" (Bob)

"pubkey": "021424787d68460022599d058866251192ea2abe7778781946687e6d0076511822"

One new public key for Carol is automatically added to each order:

tb1qlm6k7sg5yl0xjujppsmmee25pdwramjq370f93 (Carol)

"pubkey": "03e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a"

2of3 multisig address is created using the above 3 keys when an order is executed:

bitcoin-cli createmultisig 2 "[\"03217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a39\",\"021424787d68460022599d058866251192ea2abe7778781946687e6d0076511822\",\"03e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a\"]"
{
  "address": "2N9pimWivhqQx2mKYL4arE6YB15HtGrc7hZ",
  "redeemScript": "522103217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a3921021424787d68460022599d058866251192ea2abe7778781946687e6d00765118222103e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a53ae",
  "descriptor": "sh(multi(2,03217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a39,021424787d68460022599d058866251192ea2abe7778781946687e6d0076511822,03e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a))#scwqjskc"
}

Alice sends 0.01 BTC to multisig address 2N9pimWivhqQx2mKYL4arE6YB15HtGrc7hZ for this order: https://mempool.space/testnet/tx/a061d35e6ca82b7622d33afb1d4ee4d0a7a93125fefa6394fdba6f35c72c14d9

This multisig address should be imported in Bitcoin Core wallets (W1 and W2) used for signing PSBT:

bitcoin-cli importmulti '[{"desc" : "sh(multi(2,03217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a39,021424787d68460022599d058866251192ea2abe7778781946687e6d0076511822,03e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a))#scwqjskc","timestamp" : "now","label" : "test", "watchonly": true}]'

A release transaction is created to spend funds sent to multisig earlier with 2 outputs (one belongs to Bob and other to Carol):

bitcoin-cli createpsbt "[{\"txid\":\"a061d35e6ca82b7622d33afb1d4ee4d0a7a93125fefa6394fdba6f35c72c14d9\",\"vout\":1}]" "[{\"tb1qnh8vju93xxrv7fw25l49d8lkzjgl9v02q4ppfu\":\"0.008\"},{\"tb1qxm27rdc6yu7ne4fvxx5yv4k0l4gxqq7x575xe8\":\"0.001\"}]"

cHNidP8BAHECAAAAAdkULMc1b7r9lGP6/iUxqafQ5E4d+zrTInYrqGxe02GgAQAAAAD/////AgA1DAAAAAAAFgAUnc7JcLExhs8lyqfqVp/2FJHyseqghgEAAAAAABYAFDbV4bcaJz081SwxqEZWz/1QYAPGAAAAAAAAAAA=

Alice signs the transaction in W1 wallet:

bitcoinc-cli walletprocesspsbt "cHNidP8BAHECAAAAAdkULMc1b7r9lGP6/iUxqafQ5E4d+zrTInYrqGxe02GgAQAAAAD/////AgA1DAAAAAAAFgAUnc7JcLExhs8lyqfqVp/2FJHyseqghgEAAAAAABYAFDbV4bcaJz081SwxqEZWz/1QYAPGAAAAAAAAAAA="


{
  "psbt": "cHNidP8BAHECAAAAAdkULMc1b7r9lGP6/iUxqafQ5E4d+zrTInYrqGxe02GgAQAAAAD/////AgA1DAAAAAAAFgAUnc7JcLExhs8lyqfqVp/2FJHyseqghgEAAAAAABYAFDbV4bcaJz081SwxqEZWz/1QYAPGAAAAAAABAJsCAAAAAqxrJHcjYShzLjZA9T0wAOE9zTPnCboZ0a8rbG9pOopoAAAAAAD9////0CI9e1hwb3LkDXDiQP1+tXO2EaHbVGi53ldRcxCSom0BAAAAAP3///8CLjQMAAAAAAAWABSdoFV8AP5cUpFelzDVc4Lq9ZbM90BCDwAAAAAAF6kUtdfDch3LRwHRvWiuXOMUsKJ4kRuH/JMgACICAyF8H5/pdbvJ8v391uQkcXnxiNu41Thh7vN4KxZJzUo5RzBEAiAq9rcpVkDatISC9FLzC53IwOuYR9Wd6p4YZtFRx8WbHQIgBEWPDZE0xQ73dR4RMHDQBGxK5eMaNb6xOnoZZZ2Bgy4BAQRpUiEDIXwfn+l1u8ny/f3W5CRxefGI27jVOGHu83grFknNSjkhAhQkeH1oRgAiWZ0FiGYlEZLqKr53eHgZRmh+bQB2URgiIQPpo/dGtv6aM055MJhn7JZNie8xvpUY1vUL8gfcV4jpOlOuIgYCFCR4fWhGACJZnQWIZiURkuoqvnd4eBlGaH5tAHZRGCIEiSxmOSIGAyF8H5/pdbvJ8v391uQkcXnxiNu41Thh7vN4KxZJzUo5BOtGeqkiBgPpo/dGtv6aM055MJhn7JZNie8xvpUY1vUL8gfcV4jpOgT+9W9BAAAA",
  "complete": false
}

PSBT is shared with Bob and he signs it in W2 wallet:

bitcoin-cli walletprocesspsbt "cHNidP8BAHECAAAAAdkULMc1b7r9lGP6/iUxqafQ5E4d+zrTInYrqGxe02GgAQAAAAD/////AgA1DAAAAAAAFgAUnc7JcLExhs8lyqfqVp/2FJHyseqghgEAAAAAABYAFDbV4bcaJz081SwxqEZWz/1QYAPGAAAAAAABAJsCAAAAAqxrJHcjYShzLjZA9T0wAOE9zTPnCboZ0a8rbG9pOopoAAAAAAD9////0CI9e1hwb3LkDXDiQP1+tXO2EaHbVGi53ldRcxCSom0BAAAAAP3///8CLjQMAAAAAA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8gsg0eSmxJDUAWHDVp7pkDr6bk3GN4wIvBbQFMaVIhAyF8H5/pdbvJ8v391uQkcXnxiNu41Thh7vN4KxZJzUo5IQIUJHh9aEYAIlmdBYhmJRGS6iq+d3h4GUZofm0AdlEYIiED6aP3Rrb+mjNOeTCYZ+yWTYnvMb6VGNb1C/IH3FeI6TpTrgAAAA==",
  "complete": true
}

Carol will finalize PSBT and broadcast the transaction:

bitcoin-cli finalizepsbt "cHNidP8BAHECAAAAAdkULMc1b7r9lGP6/iUxqafQ5E4d+zrTInYrqGxe02GgAQAAAAD/////AgA1DAAAAAAAFgAUnc7JcLExhs8lyqfqVp/2FJHyseqghgEAAAAAABYAFDbV4bcaJz081SwxqEZWz/1QYAPGAAAAAAABAJsCAAAAAqxrJHcjYShzLjZA9T0wAOE9zTPnCboZ0a8rbG9pOopoAAAAAAD9////0CI9e1hwb3LkDXDiQP1+tXO2EaHbVGi53ldRcxCSom0BAAAAAP3///8CLjQMAAAAAAAWABSdoFV8AP5cUpFelzDVc4Lq9ZbM90BCDwAAAAAAF6kUtdfDch3LRwHRvWiuXOMUsKJ4kRuH/JMgAAEH/ABHMEQCICr2tylWQNq0hIL0UvMLncjA65hH1Z3qnhhm0VHHxZsdAiAERY8NkTTFDvd1HhEwcNAEbErl4xo1vrE6ehllnYGDLgFHMEQCIAO7GxP6x/YXYyCd0+FshbZJ/cSEKuqlnpiWgsAA1Hf0AiAqqq3QIR8gsg0eSmxJDUAWHDVp7pkDr6bk3GN4wIvBbQFMaVIhAyF8H5/pdbvJ8v391uQkcXnxiNu41Thh7vN4KxZJzUo5IQIUJHh9aEYAIlmdBYhmJRGS6iq+d3h4GUZofm0AdlEYIiED6aP3Rrb+mjNOeTCYZ+yWTYnvMb6VGNb1C/IH3FeI6TpTrgAAAA=="
{
  "hex": "0200000001d9142cc7356fbafd9463fafe2531a9a7d0e44e1dfb3ad322762ba86c5ed361a001000000fc0047304402202af6b7295640dab48482f452f30b9dc8c0eb9847d59dea9e1866d151c7c59b1d022004458f0d9134c50ef7751e113070d0046c4ae5e31a35beb13a7a19659d81832e01473044022003bb1b13fac7f61763209dd3e16c85b649fdc4842aeaa59e989682c000d477f402202aaaadd0211f20b20d1e4a6c490d40161c3569ee9903afa6e4dc6378c08bc16d014c69522103217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a3921021424787d68460022599d058866251192ea2abe7778781946687e6d00765118222103e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a53aeffffffff0200350c00000000001600149dcec970b13186cf25caa7ea569ff61491f2b1eaa08601000000000016001436d5e1b71a273d3cd52c31a84656cffd506003c600000000",
  "complete": true
}

bitcoin-cli sendrawtransaction 0200000001d9142cc7356fbafd9463fafe2531a9a7d0e44e1dfb3ad322762ba86c5ed361a001000000fc0047304402202af6b7295640dab48482f452f30b9dc8c0eb9847d59dea9e1866d151c7c59b1d022004458f0d9134c50ef7751e113070d0046c4ae5e31a35beb13a7a19659d81832e01473044022003bb1b13fac7f61763209dd3e16c85b649fdc4842aeaa59e989682c000d477f402202aaaadd0211f20b20d1e4a6c490d40161c3569ee9903afa6e4dc6378c08bc16d014c69522103217c1f9fe975bbc9f2fdfdd6e4247179f188dbb8d53861eef3782b1649cd4a3921021424787d68460022599d058866251192ea2abe7778781946687e6d00765118222103e9a3f746b6fe9a334e79309867ec964d89ef31be9518d6f50bf207dc5788e93a53aeffffffff0200350c00000000001600149dcec970b13186cf25caa7ea569ff61491f2b1eaa08601000000000016001436d5e1b71a273d3cd52c31a84656cffd506003c600000000

dad03ca8744b4809cadaa903f06a2baa5ae54bedd5bfadcdab14f3761599058d

transaction

https://mempool.space/testnet/tx/dad03ca8744b4809cadaa903f06a2baa5ae54bedd5bfadcdab14f3761599058d

6
  • Does that mean that I also have to create wallet for them? It would mean that they cannot use their existing wallet like on Coinbase or such?
    – FosAvance
    Jan 8 at 20:43
  • You won't have to create wallets for them but will need public keys from their wallet. Or else you could improve UI/UX with a browser extension that does everything in the background using Bitcoin Core JSON RPC and website API. Coinbase wallet won't work for any of these things.
    – user103136
    Jan 8 at 20:56
  • I see. Thanks, at least it gives me some direction
    – FosAvance
    Jan 8 at 23:37
  • @FosAvance Note that many (almost all?) wallets will not support the functionality required for this to work (ie, ability to retrieve public keys, and sign multi-sig PSBTs). This scheme would also leave you vulnerable to Alice and Bob completing the payment without paying you your fee (they could coordinate to create a transaction that just pays it back to bob, for example).
    – chytrik
    Jan 9 at 9:14
  • @chytrik both have solutions. 1. Inform and ask the users to use wallets that support PSBT and multisig. Lot of wallets/projects with better UI/UX allow this including some hardware wallets. 2. This is a problem with P2P market which can be managed by creating incentives for users to use the platform for orders instead of settling outside. Example: Reputation, Points, Tokens etc. 3. Hodlhodl manages both issues in a diff way that users are unaware of things involved but still use 2of3 multisig for each P2P trade: gitlab.com/hodlhodl-public/hodl-client-js/-/blob/master/…
    – user103136
    Jan 9 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.