Skip to content

Commit 87f83ef

Browse files
quetoolCopilot
andauthored
[TVF] Bitcoin (#177)
* Bitcoin TVF * merge conflicts and test * Update packages/reown_sign/lib/sign_engine.dart Co-authored-by: Copilot <[email protected]> * merge conflicts --------- Co-authored-by: Copilot <[email protected]>
1 parent 7123ce1 commit 87f83ef

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/reown_core/lib/models/tvf_data.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class TVFData {
4444
'solana_signTransaction',
4545
'solana_signAllTransactions',
4646
'wallet_sendCalls',
47+
// Bitcoin
48+
'sendTransfer',
4749
// Hedera
4850
'hedera_signAndExecuteTransaction',
4951
'hedera_executeTransaction',

packages/reown_core/test/utils_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,24 @@ void main() {
172172
);
173173
expect(transactionId, '[email protected]');
174174
});
175+
176+
test('should parse bitcoin\'s sendTransfer and extract txid', () {
177+
final jsonRPCResponse = {
178+
'jsonrpc': '2.0',
179+
'id': 1,
180+
'result': {
181+
'txid':
182+
'f007551f169722ce74104d6673bd46ce193c624b8550889526d1b93820d725f7'
183+
},
184+
};
185+
final response = JsonRpcResponse.fromJson(jsonRPCResponse);
186+
final result = (response.result as Map<String, dynamic>);
187+
final txid = ReownCoreUtils.recursiveSearchForMapKey(
188+
result,
189+
'txid',
190+
);
191+
expect(txid,
192+
'f007551f169722ce74104d6673bd46ce193c624b8550889526d1b93820d725f7');
193+
});
175194
});
176195
}

packages/reown_sign/lib/sign_engine.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2998,9 +2998,21 @@ class ReownSign implements IReownSign {
29982998
core.logger.e('[$runtimeType] _collectHashes: hedera, $e');
29992999
}
30003000
return null;
3001+
case 'bip122':
3002+
try {
3003+
final result = (response.result as Map<String, dynamic>);
3004+
final txId = ReownCoreUtils.recursiveSearchForMapKey(
3005+
result,
3006+
'txid',
3007+
);
3008+
return <String>[txId];
3009+
} catch (e) {
3010+
core.logger.e('[$runtimeType] _collectHashes: bip122, $e');
3011+
}
3012+
return null;
30013013
default:
30023014
// default to EVM
3003-
return List<String>.from([response.result]);
3015+
return <String>[response.result];
30043016
}
30053017
}
30063018
}

0 commit comments

Comments
 (0)