Author Topic: Bounty feature  (Read 1935 times)

Mithril Man

  • Hero Member
  • *****
  • Posts: 589
    • View Profile
    • Mithril Man Web!
Bounty feature
« on: March 12, 2015, 03:14:45 PM »
hey ya,
I want to implement a bounty feature, where a player within my client can set a bounty that mean "kill player XXX"
then whenever the target die, i wait some confirmation than i decode the transaction to get who killed him
once i get the killer, i send the bounty to his address

this way anyone can get the bounty, my client would be needed just to set bounties (but any client that allow people to type OP_RETURN value can send bounty money to my specific address, specifying in OP_RETURN who's the target (based on my specs, could be just something like WANTED:hunterName.0

now, i've some questions about this:
what's the best way to get a "killed by" transaction? should i parse last block everytime a new block has been added?

there is then the REORG problem, to handle that i think i could just, every block, get the block generated MIN_CONFIRMATION blocks before
e.g. with MIN_CONFIRMATION =100, if block 683140 arrive, i can parse block 683040, looking in every transaction if it cointains some "killed by" information

does it sounds right? anything i miss about that?
If yes i just need to know who to get the "killed by" information
Alternative GUI client for Huntercoin http://www.mithrilman.com
HUC donation: HMSCYGYJ5wo9FiniVU4pXWGUu8E8PSmoHE
BTC donation: 1DKLf1QKAZ5njucq37pZhMRG67qXDP3vPC

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: Bounty feature
« Reply #1 on: March 13, 2015, 06:46:34 AM »
Yes, sounds about right.  Maybe one can devise some clever tricks in order to make the bounty-paying tx automatically invalid in a reorg, then you don't have to wait for the confirmations.  I've no idea about how to do that so far, though.  Just waiting some time seems fine.

You can find the game transaction(s) in the "getblock" output (field "game_tx").  There may be up to two of them, one for paying out bounties (banked coins and general refunds) and one for killing hunters.  If one (or both) of them has no effect (no banking or killing occured in the block), then the tx won't be there at all.  You can find the code that handles these tx (including how they are built) in gametx.cpp, if you want to take a look.  The killing tx has no outputs (while the banking tx has outputs, obviously), which you can use to spot it.

Then take a look at each input, which corresponds to a killed general.  (For killed non-generals, if you want to support them even though they may be removed in the future, you have to look at the game state.  There are no tx for them.)  The script (you can look at the "asm" of the raw tx) gives the details about who was killed, how it died and who was/were the killer(s) if applicable.  For the format, see the comment at the beginning of gametx.cpp.

Let me know if you need further info.
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

Mithril Man

  • Hero Member
  • *****
  • Posts: 589
    • View Profile
    • Mithril Man Web!
Re: Bounty feature
« Reply #2 on: March 13, 2015, 02:20:28 PM »
thanks i will try to follow your infos!
I've to find some of the blocks with such data, if anyone has fast access to those information, I just need a block where someone has been killed, so i don't have to browse the chain, anyway i'll go on
Alternative GUI client for Huntercoin http://www.mithrilman.com
HUC donation: HMSCYGYJ5wo9FiniVU4pXWGUu8E8PSmoHE
BTC donation: 1DKLf1QKAZ5njucq37pZhMRG67qXDP3vPC

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: Bounty feature
« Reply #3 on: March 14, 2015, 10:59:42 AM »
I can also add a JSON decode of the data to decoderawtransaction (plus friends that return such data).  Would that help you, or can you just as easily do it yourself?
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

Mithril Man

  • Hero Member
  • *****
  • Posts: 589
    • View Profile
    • Mithril Man Web!
Re: Bounty feature
« Reply #4 on: March 14, 2015, 01:00:26 PM »
I can also add a JSON decode of the data to decoderawtransaction (plus friends that return such data).  Would that help you, or can you just as easily do it yourself?

well if it easy to you thana would be nice for everyone, even for block explorer i guess
Alternative GUI client for Huntercoin http://www.mithrilman.com
HUC donation: HMSCYGYJ5wo9FiniVU4pXWGUu8E8PSmoHE
BTC donation: 1DKLf1QKAZ5njucq37pZhMRG67qXDP3vPC

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: Bounty feature
« Reply #5 on: March 15, 2015, 10:37:42 PM »
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu