Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet integration #32

Closed
4 tasks done
akernest opened this issue Jan 4, 2016 · 2 comments
Closed
4 tasks done

Wallet integration #32

akernest opened this issue Jan 4, 2016 · 2 comments

Comments

@akernest
Copy link

akernest commented Jan 4, 2016

All matters related to creating a BlockchainWallet which connects to a real blockchain/wallet, and can sign/broadcast transactions (see: #40)

  • Create websocket server in app which listens for web wallet to connect
  • Send notification to web wallet specifying which IP/port to connect to
  • Define API between web wallet and app
  • Implement API between web wallet and app, connecting app infrastructure to wallet
@nathanielhourt
Copy link
Contributor

nathanielhourt commented Jun 1, 2016

Spec for Bitshares wallet 3rd party API

Format for method signatures:

method (arg :type, [...]) => (result :type, [...])
Protocol to be implemented via JSON-RPC 2.0 over a websockets connection

Blockchain Queries

  • getObjectById (objectId :Text) => (object :Object)
    • Retrieves an object by ID (i.e. "1.5.2")
    • Returns the object JSON, i.e:
{
  "id": "1.5.2",
  "committee_member_account": "1.2.90744",
  "vote_id": "0:13",
  "total_votes": "20599522639597",
  "url": ""
}
  • getBlockByHeight (blockHeight :UInt64) => (block :BlockObject)
    • Get the block at the specified height
    • Returns the block, i.e.:
{
  "previous": "000000092313e07390edd87d6c87ed1280560654",
  "timestamp": "2016-08-09T15:53:00",
  "witness": "1.6.9",
  "transaction_merkle_root": "0000000000000000000000000000000000000000",
  "extensions": [],
  "witness_signature": "1f389c2b2084da3ad736c0f37deda4cc229a9700a8ef7d54c91d7d7f699c3b29bb78dc6c314dcea6cba7d53144a15c2d71d5fced5d52938b80b42a239cc332e7ff",
  "transactions": [],
  "block_id": "0000000abeaa15183d6db0f3b96eb300357edb6b",
  "signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
  "transaction_ids": []
}
  • getAssetBySymbol (assetSymbol :Text) => (asset :AssetObject)
    • Same as getAssetById, except takes a symbol instead of an ID
    • Returns an asset object, like getAssetById
  • getAllAssets () => (assets :List(AssetSummaryObject))
    • Retrieves summaries of all assets known to blockchain
    • Returns a list of summary objects, i.e:
[
  {"id": "1.3.0", symbol: "BTS", "precision": 4, "issuer": "null-account"},
  {"id": "1.3.100", symbol: "GAS", "precision": 4, "issuer": "committee-account"},
  ...
]
  • getAccountByName (accountName :Text) => (account :AccountObject)
    • Retrieves the account object bearing the specified name
    • Returns an account object, i.e:
{
  "id": "1.2.11023",
  "membership_expiration_date": "1969-12-31T23:59:59",
  "registrar": "1.2.11023",
  "referrer": "1.2.11023",
  "lifetime_referrer": "1.2.11023",
  "network_fee_percentage": 2000,
  "lifetime_referrer_fee_percentage": 8000,
  "referrer_rewards_percentage": 0,
  "name": "follow-my-vote",
  "owner": {
    "weight_threshold": 1,
    "account_auths": [],
    "key_auths": [[
        "BTS6wxReMNstW7XNfzRPAq4DEoNNNkAwH9zUmryN29zFyeywVADJQ",
        1
      ]
    ],
    "address_auths": []
  },
  "active": {
    "weight_threshold": 100,
    "account_auths": [[
        "1.2.298",
        50
      ],[
        "1.2.306",
        50
      ]
    ],
    "key_auths": [],
    "address_auths": []
  },
  "options": {
    "memo_key": "BTS6wxReMNstW7XNfzRPAq4DEoNNNkAwH9zUmryN29zFyeywVADJQ",
    "voting_account": "1.2.5",
    "num_witness": 0,
    "num_committee": 0,
    "votes": [],
    "extensions": []
  },
  "statistics": "2.6.11023",
  "whitelisting_accounts": [],
  "blacklisting_accounts": [],
  "whitelisted_accounts": [],
  "blacklisted_accounts": [],
  "cashback_vb": "1.13.120",
  "owner_special_authority": [
    0,{}
  ],
  "active_special_authority": [
    0,{}
  ],
  "top_n_control_flags": 0
}
  • getAccountBalances (accountNameOrId :Text) => (balances :List(BalanceObject))
    • Retrieves all balances the named account owns
    • Named account does not need to be controlled by this wallet
    • Returns a list of balances, i.e:
[{"amount": 12300000, "type": "1.3.0"}, {"amount": 50000, "type": "1.3.100"}, ...]
  • getAccountHistory (accountNameOrId :Text) => (history :List(OperationSummaryObject))
    • Retrieves the list of operations this account has performed in its lifetime
    • Returns a list of operation summaries, consisting of operation history id "id" and operation tag "tag", ordered from most recent to oldest
    • "id" is the operation_history_id_type for the operation
    • "opCode" is the operation tag (0 for transfer_operation, 1 for limit_order_create_operation, etc)
[{"id": "1.11.57261", "opCode": 19}, {"id": "1.11.47164", "opCode": 22}, ...]
  • getAccountHistoryByOpCode (accountNameOrId :Text, opCode :UInt64) => (history :List(OperationId))
    • A filtered version of getAccountHistory
    • Returns only the operation IDs having opCode as their operation tag, ordered from most recent to oldest, i.e:
["1.11.57261", "1.11.40023", "1.11.28625", ...]
  • getTransactionFees (operations :List(OperationObject)) => (fees :List(OperationObject))
    • Calculate the fees to broadcast a transaction containing the provided operations
    • OperationObject is formatted as {"code": opCode, "op": Operation}
      • Operation is the content of the operation; its contents depend on the operation type specified by "code"
      • Operation in arguments may or may not contain the fee field, but this field should be ignored if present
    • Returns operations with fee fields set
      • Wallet may choose asset to use for fees at its discretion
      • Should set fees automatically, without asking user
[  
  {  
    "code":0,
    "op":{  
      "fee":{  
        "amount":264174,
        "asset_id":"1.3.0"
      },
      "from":"1.2.150",
      "to":"1.2.659",
      "amount":{  
        "amount":50000000,
        "asset_id":"1.3.0"
      },
      "extensions":[  

      ]
    }
  },
  ...
]

Wallet Queries

  • unlockWallet ()
    • Prompts user to unlock wallet; if wallet is already unlocked, do nothing
    • Implement as notification with no return value
  • getMyAccounts () => (accountNames :List(Text))
    • Retrieves all accounts which this wallet controls
    • Returns a list of account names, i.e:
["nathan", "follow-my-vote", "dev.nathanhourt.com"]
  • signJsonObject (object :Text, signingAccountName :Text) => (signature :Text)
    • Signs the JSON object serialized as object using signingAccountName's memo key
    • object must be a string containing a valid JSON object
    • signingAccountName must be a member of the list returned by getSigningAccounts
    • Returns hex-encoded signature on object
  • broadcastTransaction (operations :List(OperationObject)) => (transactionId :Text)
    • Construct a transaction containing the provided operations, and broadcast it
    • If wallet cannot fully sign for the transaction, it may propose the transaction using an account at its discretion
    • OperationObjects are formatted like in getTransactionFees, but must have valid fees set
      • Wallet may replace fees with other asset prior to broadcasting at its discretion
      • Wallet may not change fee paying accounts
    • Returns a hex-encoded transaction ID
      • Must not return until transaction has been broadcast (may take arbitrarily long, i.e. getting user authorization)
      • May return before transaction has been included in chain
  • getSharedSecret (myAccountNameOrId :Text, otherAccountNameOrId :Text) => (secret :Text)
    • Computes the shared secret between my account's private memo key and other account's public memo key
    • Returns hex-encoded 512-bit shared secret

nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 1, 2016
Lay the groundwork for the RPC interface to the Bitshares wallet
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 1, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 6, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 10, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 14, 2016
Progress on the API. Also, make canonical the fact that a Balance
object's ID (on Bitshares) is the combinaion of the owning account ID
and the asset ID; define a struct so we can parse them with
BlobMessageReaders.
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 15, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 28, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 30, 2016
I'm now testing on a real graphene testnet!
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jun 30, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jul 2, 2016
The wallet API is now complete. Still some work on the app side. Also,
lots of work here debugging the server side so that it sees the
transfers coming in and creates contests correctly. It doesn't create
the contests correctly yet, but I'm getting really close!
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jul 5, 2016
…orks

Full process of creating it in the app, purchasing it from the server,
the server seeing the purchase on the chain, publishing the contest,
finding the published contest, adding it to the database of contests,
listing it to the client when the client asks for the contest feed, the
client fetching the contest from the blockchain, and displaying it in
the GUI. Now works. *whew*
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jul 7, 2016
nathanielhourt added a commit to nathanielhourt/StakeWeightedVoting that referenced this issue Jul 7, 2016
@nathanielhourt
Copy link
Contributor

nathanielhourt commented Jul 7, 2016

The API is finished. Wallet integration is complete, at least for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants