{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/199330061","pull_request_review_id":133433770,"id":199330061,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTMzMDA2MQ==","diff_hunk":"@@ -4388,6 +4391,333 @@ UniValue sethdseed(const JSONRPCRequest& request)\n     return NullUniValue;\n }\n \n+bool ParseHDKeypath(std::string keypath_str, std::vector<uint32_t>& keypath)\n+{\n+    std::stringstream ss(keypath_str);\n+    std::string item;\n+    bool first = true;\n+    while (std::getline(ss, item, '/')) {\n+        if (item.compare(\"m\") == 0) {\n+            if (first) {\n+                first = false;\n+                continue;\n+            }\n+            return false;\n+        }\n+        // Finds whether it is hardened\n+        uint32_t path = 0;\n+        size_t pos = item.find(\"'\");\n+        if (pos != std::string::npos) {\n+            // The hardened tick can only be in the last index of the string\n+            if (pos != item.size() - 1) {\n+                return false;\n+            }\n+            path |= 0x80000000;\n+            item = item.substr(0, item.size() - 1); // Drop the last character which is the hardened tick\n+        }\n+\n+        // Ensure this is only numbers\n+        if (item.find_first_not_of( \"0123456789\" ) != std::string::npos) {\n+            return false;\n+        }\n+        uint32_t number;\n+        ParseUInt32(item, &number);\n+        path |= number;\n+\n+        keypath.push_back(path);\n+        first = false;\n+    }\n+    return true;\n+}\n+\n+void AddKeypathToMap(const CWallet* pwallet, const CKeyID& keyID, std::map<CPubKey, std::vector<uint32_t>>& hd_keypaths)\n+{\n+    CPubKey vchPubKey;\n+    if (!pwallet->GetPubKey(keyID, vchPubKey)) {\n+        return;\n+    }\n+    CKeyMetadata meta;\n+    auto it = pwallet->mapKeyMetadata.find(keyID);\n+    if (it != pwallet->mapKeyMetadata.end()) {\n+        meta = it->second;\n+    }\n+    std::vector<uint32_t> keypath;\n+    if (!meta.hdKeypath.empty()) {\n+        if (!ParseHDKeypath(meta.hdKeypath, keypath)) {\n+            throw JSONRPCError(RPC_INTERNAL_ERROR, \"Internal keypath is broken\");\n+        }\n+        // Get the proper master key id\n+        CKey key;\n+        pwallet->GetKey(meta.hd_seed_id, key);\n+        CExtKey masterKey;\n+        masterKey.SetSeed(key.begin(), key.size());\n+        // Add to map\n+        keypath.insert(keypath.begin(), ReadLE32(masterKey.key.GetPubKey().GetID().begin()));\n+    }\n+    // Single pubkeys get the master fingerprint of themselves\n+    else {\n+        keypath.insert(keypath.begin(), ReadLE32(vchPubKey.GetID().begin()));\n+    }\n+    hd_keypaths.emplace(vchPubKey, keypath);\n+}\n+\n+bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const CTransaction* txConst, int sighash_type, bool sign)\n+{\n+    // Get all of the previous transactions\n+    bool complete = true;\n+    for (unsigned int i = 0; i < txConst->vin.size(); ++i) {\n+        CTxIn txin = txConst->vin[i];\n+        PSBTInput& input = psbtx.inputs.at(i);\n+\n+        // If we don't know about this input, skip it and let someone else deal with it\n+        uint256 txhash = txin.prevout.hash;","path":"src/wallet/rpcwallet.cpp","position":317,"original_position":317,"commit_id":"a871194feebc4152ecc2130adcb67f3521c42dc8","original_commit_id":"a871194feebc4152ecc2130adcb67f3521c42dc8","user":{"login":"sipa","id":548488,"node_id":"MDQ6VXNlcjU0ODQ4OA==","avatar_url":"https://avatars1.githubusercontent.com/u/548488?v=4","gravatar_id":"","url":"https://api.github.com/users/sipa","html_url":"https://github.com/sipa","followers_url":"https://api.github.com/users/sipa/followers","following_url":"https://api.github.com/users/sipa/following{/other_user}","gists_url":"https://api.github.com/users/sipa/gists{/gist_id}","starred_url":"https://api.github.com/users/sipa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sipa/subscriptions","organizations_url":"https://api.github.com/users/sipa/orgs","repos_url":"https://api.github.com/users/sipa/repos","events_url":"https://api.github.com/users/sipa/events{/privacy}","received_events_url":"https://api.github.com/users/sipa/received_events","type":"User","site_admin":false},"body":"Same here.","created_at":"2018-06-30T19:09:06Z","updated_at":"2018-06-30T19:20:09Z","html_url":"https://github.com/bitcoin/bitcoin/pull/13557#discussion_r199330061","pull_request_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/199330061"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/13557#discussion_r199330061"},"pull_request":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557"}}},"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557","id":197905130,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3OTA1MTMw","html_url":"https://github.com/bitcoin/bitcoin/pull/13557","diff_url":"https://github.com/bitcoin/bitcoin/pull/13557.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/13557.patch","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13557","number":13557,"state":"open","locked":false,"title":"BIP 174 PSBT Serializations and RPCs","user":{"login":"achow101","id":3782274,"node_id":"MDQ6VXNlcjM3ODIyNzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3782274?v=4","gravatar_id":"","url":"https://api.github.com/users/achow101","html_url":"https://github.com/achow101","followers_url":"https://api.github.com/users/achow101/followers","following_url":"https://api.github.com/users/achow101/following{/other_user}","gists_url":"https://api.github.com/users/achow101/gists{/gist_id}","starred_url":"https://api.github.com/users/achow101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achow101/subscriptions","organizations_url":"https://api.github.com/users/achow101/orgs","repos_url":"https://api.github.com/users/achow101/repos","events_url":"https://api.github.com/users/achow101/events{/privacy}","received_events_url":"https://api.github.com/users/achow101/received_events","type":"User","site_admin":false},"body":"This Pull Request fully implements the [updated](https://github.com/bitcoin/bips/pull/694) BIP 174 specification. It is based upon #13425 which implements the majority of the signing logic.\r\n\r\nBIP 174 specifies a binary transaction format which contains the information necessary for a signer to produce signatures for the transaction and holds the signatures for an input while the input does not have a complete set of signatures.\r\n\r\nThis PR contains structs for PSBT, serialization, and deserialzation code. Some changes to `SignatureData` have been made to support detection of UTXO type and storing public keys.\r\n\r\n***\r\n\r\nMany RPCs have been added to handle PSBTs.\r\n\r\n`walletprocesspsbt` takes a PSBT format transaction, updates the PSBT with any inputs related to this wallet, signs, and finalizes the transaction. There is also an option to not sign and just update.\r\n\r\n`walletcreatefundedpsbt` creates a PSBT from user provided data in the same form as createrawtransaction. It also funds the transaction and takes an options argument in the same form as `fundrawtransaction`. The resulting PSBT is blank with no input or output data filled in. It is analogous to a combination of `createrawtransaction` and `fundrawtransaction`\r\n\r\n`decodepsbt` takes a PSBT and decodes it to JSON. It is analogous to `decoderawtransaction`\r\n\r\n`combinepsbt` takes multiple PSBTs for the same tx and combines them. It is analogous to `combinerawtransaction`\r\n\r\n`finalizepsbt` takes a PSBT and finalizes the inputs. If all inputs are final, it extracts the network serialized transaction and returns that instead of a PSBT unless instructed otherwise.\r\n\r\n`createpsbt` is like `createrawtransaction` but for PSBTs instead of raw transactions.\r\n\r\n`convertpsbt` takes a network serialized transaction and converts it into a psbt. The resulting psbt will lose all signature data and an explicit flag must be set to allow transactions with signature data to be converted.\r\n\r\n***\r\n\r\nThis supersedes #12136","created_at":"2018-06-28T03:04:17Z","updated_at":"2018-06-30T19:20:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c15f541f13dec9881575176d1c3603d06f484eb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557/commits","review_comments_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557/comments","review_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13557/comments","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/a871194feebc4152ecc2130adcb67f3521c42dc8","head":{"label":"achow101:psbt","ref":"psbt","sha":"a871194feebc4152ecc2130adcb67f3521c42dc8","user":{"login":"achow101","id":3782274,"node_id":"MDQ6VXNlcjM3ODIyNzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3782274?v=4","gravatar_id":"","url":"https://api.github.com/users/achow101","html_url":"https://github.com/achow101","followers_url":"https://api.github.com/users/achow101/followers","following_url":"https://api.github.com/users/achow101/following{/other_user}","gists_url":"https://api.github.com/users/achow101/gists{/gist_id}","starred_url":"https://api.github.com/users/achow101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achow101/subscriptions","organizations_url":"https://api.github.com/users/achow101/orgs","repos_url":"https://api.github.com/users/achow101/repos","events_url":"https://api.github.com/users/achow101/events{/privacy}","received_events_url":"https://api.github.com/users/achow101/received_events","type":"User","site_admin":false},"repo":{"id":45006379,"node_id":"MDEwOlJlcG9zaXRvcnk0NTAwNjM3OQ==","name":"bitcoin","full_name":"achow101/bitcoin","owner":{"login":"achow101","id":3782274,"node_id":"MDQ6VXNlcjM3ODIyNzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3782274?v=4","gravatar_id":"","url":"https://api.github.com/users/achow101","html_url":"https://github.com/achow101","followers_url":"https://api.github.com/users/achow101/followers","following_url":"https://api.github.com/users/achow101/following{/other_user}","gists_url":"https://api.github.com/users/achow101/gists{/gist_id}","starred_url":"https://api.github.com/users/achow101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achow101/subscriptions","organizations_url":"https://api.github.com/users/achow101/orgs","repos_url":"https://api.github.com/users/achow101/repos","events_url":"https://api.github.com/users/achow101/events{/privacy}","received_events_url":"https://api.github.com/users/achow101/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/achow101/bitcoin","description":"Bitcoin Core integration/staging tree","fork":true,"url":"https://api.github.com/repos/achow101/bitcoin","forks_url":"https://api.github.com/repos/achow101/bitcoin/forks","keys_url":"https://api.github.com/repos/achow101/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/achow101/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/achow101/bitcoin/teams","hooks_url":"https://api.github.com/repos/achow101/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/achow101/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/achow101/bitcoin/events","assignees_url":"https://api.github.com/repos/achow101/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/achow101/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/achow101/bitcoin/tags","blobs_url":"https://api.github.com/repos/achow101/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/achow101/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/achow101/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/achow101/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/achow101/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/achow101/bitcoin/languages","stargazers_url":"https://api.github.com/repos/achow101/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/achow101/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/achow101/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/achow101/bitcoin/subscription","commits_url":"https://api.github.com/repos/achow101/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/achow101/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/achow101/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/achow101/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/achow101/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/achow101/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/achow101/bitcoin/merges","archive_url":"https://api.github.com/repos/achow101/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/achow101/bitcoin/downloads","issues_url":"https://api.github.com/repos/achow101/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/achow101/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/achow101/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/achow101/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/achow101/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/achow101/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/achow101/bitcoin/deployments","created_at":"2015-10-27T00:20:28Z","updated_at":"2018-06-28T18:39:46Z","pushed_at":"2018-06-30T02:46:10Z","git_url":"git://github.com/achow101/bitcoin.git","ssh_url":"git@github.com:achow101/bitcoin.git","clone_url":"https://github.com/achow101/bitcoin.git","svn_url":"https://github.com/achow101/bitcoin","homepage":"https://bitcoin.org/en/download","size":110264,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":6,"default_branch":"master"}},"base":{"label":"bitcoin:master","ref":"master","sha":"a6ed99a1e6facd38913711106bce6fb65bd14862","user":{"login":"bitcoin","id":528860,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUyODg2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/528860?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"repo":{"id":1181927,"node_id":"MDEwOlJlcG9zaXRvcnkxMTgxOTI3","name":"bitcoin","full_name":"bitcoin/bitcoin","owner":{"login":"bitcoin","id":528860,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUyODg2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/528860?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitcoin/bitcoin","description":"Bitcoin Core integration/staging tree","fork":false,"url":"https://api.github.com/repos/bitcoin/bitcoin","forks_url":"https://api.github.com/repos/bitcoin/bitcoin/forks","keys_url":"https://api.github.com/repos/bitcoin/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin/bitcoin/teams","hooks_url":"https://api.github.com/repos/bitcoin/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin/bitcoin/events","assignees_url":"https://api.github.com/repos/bitcoin/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin/bitcoin/tags","blobs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin/bitcoin/languages","stargazers_url":"https://api.github.com/repos/bitcoin/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/bitcoin/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/bitcoin/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/bitcoin/bitcoin/subscription","commits_url":"https://api.github.com/repos/bitcoin/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin/bitcoin/merges","archive_url":"https://api.github.com/repos/bitcoin/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin/bitcoin/downloads","issues_url":"https://api.github.com/repos/bitcoin/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/bitcoin/bitcoin/deployments","created_at":"2010-12-19T15:16:43Z","updated_at":"2018-06-30T18:04:15Z","pushed_at":"2018-06-30T15:05:36Z","git_url":"git://github.com/bitcoin/bitcoin.git","ssh_url":"git@github.com:bitcoin/bitcoin.git","clone_url":"https://github.com/bitcoin/bitcoin.git","svn_url":"https://github.com/bitcoin/bitcoin","homepage":"https://bitcoin.org/en/download","size":107440,"stargazers_count":32851,"watchers_count":32851,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":19775,"mirror_url":null,"archived":false,"open_issues_count":821,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19775,"open_issues":821,"watchers":32851,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/13557"},"issue":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/13557"},"comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/13557/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13557/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin/bitcoin/statuses/a871194feebc4152ecc2130adcb67f3521c42dc8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"sipa"}}