RPC interface / raw transactions for safe name trading

https://www.namecoin.org/dot-bit/
domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

RPC interface / raw transactions for safe name trading

Post by domob »

I'm very interested in pushing forward discussions (and eventually implementations) of "safe name trading", as was originally planned for Namecoin-Qt by Mikhail and snailbrain. This would we very useful, and also give Namecoin a huge publicity boost, as we would (AFAIK) be the first to actually implement a P2P crypto market place (instead of not just theoretising about the best ways to implement P2P trading).

As a first step towards that goal, I suggest we implement a way to do safe name trading transactions using the RPC interface for raw transactions. Then we can demonstrate it works, and work on the UI later. In particular, what I propose to do:
  • Extend "decoderawtransaction" to actually print meaningful and understandable interpretations of name scripts (and possibly also more information about the inputs), so that checking of transactions can be done. What I currently see for my last transaction updating d/domob (txid
    e9903bf33ab5c7aadd1f99f2fabab3313b97d61ecdd9b0c339ee2de914c40184):

    Code: Select all

    {
        "txid" : "e9903bf33ab5c7aadd1f99f2fabab3313b97d61ecdd9b0c339ee2de914c40184",
        "version" : 28928,
        "locktime" : 0,
        "vin" : [
            {
                "txid" : "61623985dc8fbf003eeaf1f597b4f2d5da8c46ab25dac4c388b3068696a8b425",
                "vout" : 0,
                "scriptSig" : {
                    "asm" : "30450221008706aff65986393f6df9ff0531a403d94ad9e8e2abc32271f36ee5c05e671b340220073a42971f1ef51bca744a6066fd63c1b8bffcc4896487c4bd609ea9314c628101 049d2cebbc692db1f3862d5c76a8c80a7df61cd0e0b257ebb93b9a6d41874ccf6b8e66eeb397da10434aff2577e3fa70f59b8ee1f6211831a321284986d4cdc9af",
                    "hex" : "4830450221008706aff65986393f6df9ff0531a403d94ad9e8e2abc32271f36ee5c05e671b340220073a42971f1ef51bca744a6066fd63c1b8bffcc4896487c4bd609ea9314c62810141049d2cebbc692db1f3862d5c76a8c80a7df61cd0e0b257ebb93b9a6d41874ccf6b8e66eeb397da10434aff2577e3fa70f59b8ee1f6211831a321284986d4cdc9af"
                },
                "sequence" : 4294967295
            },
            {
                "txid" : "ecd9c5f3fd7387a8dc358aedf54ec542d4a2f1ad79f50e0c964893cdc97c26da",
                "vout" : 1,
                "scriptSig" : {
                    "asm" : "3046022100bbb41321fdc2cf7adc033073931a3d80eda94759ce980173f4205b751bce9b7a022100fb49858725f872924487a6e32ece6e3b5ba32d9148630ba453b174b6972df50701 04be4e09b25d8e3d8b6b8f9b5a5276aab63ee258679124c8bc19627adadfd253d00a25ff71558deb2de05f504171fdaedb70669ae4948f3f1fe441da56d379be34",
                    "hex" : "493046022100bbb41321fdc2cf7adc033073931a3d80eda94759ce980173f4205b751bce9b7a022100fb49858725f872924487a6e32ece6e3b5ba32d9148630ba453b174b6972df507014104be4e09b25d8e3d8b6b8f9b5a5276aab63ee258679124c8bc19627adadfd253d00a25ff71558deb2de05f504171fdaedb70669ae4948f3f1fe441da56d379be34"
                },
                "sequence" : 4294967295
            }
        ],
        "vout" : [
            {
                "value" : 5.43500000,
                "n" : 0,
                "scriptPubKey" : {
                    "asm" : "04067a9140ea7c02bd9f02e459f76b28dcd2fce66d86f35c42362fa01f63141e6b377f9aaae166f33291f63f669cb644a4486cc724d432e00ea33f9a57025d80b3 OP_CHECKSIG",
                    "hex" : "4104067a9140ea7c02bd9f02e459f76b28dcd2fce66d86f35c42362fa01f63141e6b377f9aaae166f33291f63f669cb644a4486cc724d432e00ea33f9a57025d80b3ac",
                    "type" : "nonstandard"
                }
            },
            {
                "value" : 0.01000000,
                "n" : 1,
                "scriptPubKey" : {
                    "asm" : "3 642f646f6d6f62 7b22696d706f7274223a2264642f646f6d6f62227d OP_2DROP OP_DROP OP_DUP OP_HASH160 15407044c6364192a5af060d249bf038904a66f8 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex" : "5307642f646f6d6f62157b22696d706f7274223a2264642f646f6d6f62227d6d7576a91415407044c6364192a5af060d249bf038904a66f888ac",
                    "type" : "nonstandard"
                }
            }
        ]
    }
    While this makes partially sense to me, it is far from anything where I (as experienced user) could look at it and decide whether or not to sign it if I got this transaction from a trading partner. What I think we need is: Inputs that are names need to be shown as such, and other inputs need to show the amount and possibly also the address, ideally in new JSON fields. Output scripts should be decoded even more; ideally again, for currency, they should show the address (in case of OP_CHECKSIG), and for names, they should show something like "name_update: d/domob, new value, address". At least for name updates this is needed; name_firstupdate and name_new would be nice, too, but not necessary for name trading specifically.
  • Extend createrawtransaction to allow to add name operations (again, at least updates). This could be done with an optional third argument, which could be like this:

    Code: Select all

    {
      "update": {"name": "d/domob", "value": "new value", "address": "target address"},
      ...
    }
    This would allow to support other name operations in the future, too. Alternatively, it could be

    Code: Select all

    {
      "d/domob": {"value": "new value", "address": "target address"}
    }
    if that is preferred for some reason.
What do you think about these proposals? I believe that it should be "relatively" easy to implement that, and it would probably be a healthy exercise for me to do it as preparation for adding name_update & co calls to libcoin.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface / raw transactions for safe name trading

Post by domob »

Stupid me, the proposed third argument makes no sense in the first form - as multiple updates would not make valid JSON. But I hope you got the idea, we can discuss the final format.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface / raw transactions for safe name trading

Post by domob »

First part: https://github.com/namecoin/namecoin/pull/58

This makes the transaction above show as:

Code: Select all

$ namecoind getrawtransaction e9903bf33ab5c7aadd1f99f2fabab3313b97d61ecdd9b0c339ee2de914c40184 1
{
    "hex" : "[phelix sayz: lots and lots of hex here]",
    "txid" : "e9903bf33ab5c7aadd1f99f2fabab3313b97d61ecdd9b0c339ee2de914c40184",
    "version" : 28928,
    "locktime" : 0,
    "blockhash" : "d4e1874e5b8d86c88051fc1fdce6445c6875dffa7990cebfd7c6d9ac318cbb17",
    "confirmations" : 3888,
    "time" : 1393158678,
    "blocktime" : 1393158678,
    "vin" : [
        {
            "txid" : "61623985dc8fbf003eeaf1f597b4f2d5da8c46ab25dac4c388b3068696a8b425",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "30450221008706aff65986393f6df9ff0531a403d94ad9e8e2abc32271f36ee5c05e671b340220073a42971f1ef51bca744a6066fd63c1b8bffcc4896487c4bd609ea9314c628101 049d2cebbc692db1f3862d5c76a8c80a7df61cd0e0b257ebb93b9a6d41874ccf6b8e66eeb397da10434aff2577e3fa70f59b8ee1f6211831a321284986d4cdc9af",
                "hex" : "4830450221008706aff65986393f6df9ff0531a403d94ad9e8e2abc32271f36ee5c05e671b340220073a42971f1ef51bca744a6066fd63c1b8bffcc4896487c4bd609ea9314c62810141049d2cebbc692db1f3862d5c76a8c80a7df61cd0e0b257ebb93b9a6d41874ccf6b8e66eeb397da10434aff2577e3fa70f59b8ee1f6211831a321284986d4cdc9af"
            },
            "value" : 0.01000000,
            "sequence" : 4294967295
        },
        {
            "txid" : "ecd9c5f3fd7387a8dc358aedf54ec542d4a2f1ad79f50e0c964893cdc97c26da",
            "vout" : 1,
            "scriptSig" : {
                "asm" : "3046022100bbb41321fdc2cf7adc033073931a3d80eda94759ce980173f4205b751bce9b7a022100fb49858725f872924487a6e32ece6e3b5ba32d9148630ba453b174b6972df50701 04be4e09b25d8e3d8b6b8f9b5a5276aab63ee258679124c8bc19627adadfd253d00a25ff71558deb2de05f504171fdaedb70669ae4948f3f1fe441da56d379be34",
                "hex" : "493046022100bbb41321fdc2cf7adc033073931a3d80eda94759ce980173f4205b751bce9b7a022100fb49858725f872924487a6e32ece6e3b5ba32d9148630ba453b174b6972df507014104be4e09b25d8e3d8b6b8f9b5a5276aab63ee258679124c8bc19627adadfd253d00a25ff71558deb2de05f504171fdaedb70669ae4948f3f1fe441da56d379be34"
            },
            "value" : 5.44000000,
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 5.43500000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "04067a9140ea7c02bd9f02e459f76b28dcd2fce66d86f35c42362fa01f63141e6b377f9aaae166f33291f63f669cb644a4486cc724d432e00ea33f9a57025d80b3 OP_CHECKSIG",
                "hex" : "4104067a9140ea7c02bd9f02e459f76b28dcd2fce66d86f35c42362fa01f63141e6b377f9aaae166f33291f63f669cb644a4486cc724d432e00ea33f9a57025d80b3ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "N4giGkPpa84oAKswYbkcCx5YXUdBAXFcHb"
                ]
            }
        },
        {
            "value" : 0.01000000,
            "n" : 1,
            "scriptPubKey" : {
                "nameOp" : {
                    "op" : "name_update",
                    "name" : "d/domob",
                    "value" : "{\"import\":\"dd/domob\"}"
                },
                "asm" : "NAME_OPERATION OP_DUP OP_HASH160 15407044c6364192a5af060d249bf038904a66f8 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "5307642f646f6d6f62157b22696d706f7274223a2264642f646f6d6f62227d6d7576a91415407044c6364192a5af060d249bf038904a66f888ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "MxWjawkFFoEuvJtEYaJ3NmoceSoqUzE29t"
                ]
            }
        }
    ],
    "fees" : 0.00500000
}
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

phelix
Posts: 1634
Joined: Thu Aug 18, 2011 6:59 am

Re: RPC interface / raw transactions for safe name trading

Post by phelix »

I modified your post because it contained a line so long it somehow broke the forum so I could not answer.


Yes, atomic name TXs are the way to go. At least for the first implementation I would choose Python, though.

With pybitcointools I once tried to deserialize a script but could not get it to work properly. It should be possible, though.


We could then set up a bitmessage channel to broadcast partial TXs (=offers).
nx.bit - some namecoin stats
nf.bit - shortcut to this forum

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface / raw transactions for safe name trading

Post by domob »

Well, I'm not yet planning to write a full trading system and UI - for now, I just want to provide the necessary RPC commands to support front-ends (and try it out manually). As the backend for name transactions is already implemented in the daemon, I don't really see a reason for using pybitcointools (except that it would enforce Python :P).

My suggestion is to develop the trading front-end in whatever language (could be Python, although not if I implement it, since I've no experience with UI in Python so far) and use namecoind's RPC commands to handle the actual transactions.

Regarding the market place: The first thing will of course be just the ability to create atomic transactions that are brokered somewhere else (e. g., here on the forum), first manually using RPC commands (should be ready soon) and later using more comfortable command-line tools or some UI. For "automatic" posting of offers and all that, I also thought about Bitmessage already - or an IRC channel, possibly. However, it would also be possible to use the blockchain itself for that (assuming that offers do not change too often) - why not set a name's value to something indicating (in a machine-readable and standardised fashion) that it is for sale?

All the information an offer needs to include is the price, a seller's Namecoin address (could be optional, using the name's address in case it is not provided) and a contact method (could be BM address). Then, if the offer is accepted, the buyer is able to produce the unsigned transaction from just that information (buyer pays tx fee, so that the seller doesn't have to choose transaction inputs except the name) and send it to the BM address. The seller just needs to sign and broadcast the transaction.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface / raw transactions for safe name trading

Post by domob »

And another one: https://github.com/namecoin/namecoin/pull/59

This implements the possibility to create name_update's with createrawtransaction. Thus manually creating and signing atomic name transactions should now be possible. (Using both pull requests together.) Anyone willing to test it with me?

If that is merged, I will work on simple command-line tools to initiate buying a name and to finalise a trade (for the buyer and seller, respectively).
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

phelix
Posts: 1634
Joined: Thu Aug 18, 2011 6:59 am

Re: RPC interface / raw transactions for safe name trading

Post by phelix »

I wonder how in an atomic transaction with a name (special output) and normal coins (normal output) it can be
determined which output should get what...
nx.bit - some namecoin stats
nf.bit - shortcut to this forum

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface / raw transactions for safe name trading

Post by domob »

phelix wrote:I wonder how in an atomic transaction with a name (special output) and normal coins (normal output) it can be
determined which output should get what...
What exactly is your concern here? I don't fully understand what you want to say. What is the problem?
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

phelix
Posts: 1634
Joined: Thu Aug 18, 2011 6:59 am

Re: RPC interface / raw transactions for safe name trading

Post by phelix »

domob wrote:
phelix wrote:I wonder how in an atomic transaction with a name (special output) and normal coins (normal output) it can be
determined which output should get what...
What exactly is your concern here? I don't fully understand what you want to say. What is the problem?
Is it at all possible to mix a name_op and normal transfers in one transaction?

Code: Select all

a)
--->name_pout--->              --->name__out  N1234
                      TX
--->nmc__pout--->              --->nmc_out     N5678

vs.

b)
--->name_pout--->              --->nmc__out   N1234
                       TX
--->nmc__pout--->              --->name_out   N5678
How is it determined wether it should be a) or b).Would this not need something specification
about ordering the inputs/outputs like colored coins?
I never heard about something like that in Namecoin. Hopefully I am missing something here.
nx.bit - some namecoin stats
nf.bit - shortcut to this forum

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface / raw transactions for safe name trading

Post by domob »

I think you are mistaken, as far as I understand. Each individual output specifies the script necessary to redeem it (i. e., the address). So the name output as well as the coin output specify explicitly individual addresses - it is already like this, except that the coins are always change and usually both addresses belong to the same person. This is not required, though. I don't see a problem with what you write.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

Post Reply