mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
input script areas
This commit is contained in:
parent
8cf570f238
commit
d58167552a
11 changed files with 210 additions and 61 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 4d875f5ad08d728dd6959772210f1675d14fca82
|
Subproject commit d28186f8c9ca7fd53a6978b84b07e6096d55df1c
|
|
@ -103,8 +103,9 @@ public class AppController implements Initializable {
|
||||||
addTransactionTab("p2pkh", "01000000019c2e0f24a03e72002a96acedb12a632e72b6b74c05dc3ceab1fe78237f886c48010000006a47304402203da9d487be5302a6d69e02a861acff1da472885e43d7528ed9b1b537a8e2cac9022002d1bca03a1e9715a99971bafe3b1852b7a4f0168281cbd27a220380a01b3307012102c9950c622494c2e9ff5a003e33b690fe4832477d32c2d256c67eab8bf613b34effffffff02b6f50500000000001976a914bdf63990d6dc33d705b756e13dd135466c06b3b588ac845e0201000000001976a9145fb0e9755a3424efd2ba0587d20b1e98ee29814a88ac06241559", null);
|
addTransactionTab("p2pkh", "01000000019c2e0f24a03e72002a96acedb12a632e72b6b74c05dc3ceab1fe78237f886c48010000006a47304402203da9d487be5302a6d69e02a861acff1da472885e43d7528ed9b1b537a8e2cac9022002d1bca03a1e9715a99971bafe3b1852b7a4f0168281cbd27a220380a01b3307012102c9950c622494c2e9ff5a003e33b690fe4832477d32c2d256c67eab8bf613b34effffffff02b6f50500000000001976a914bdf63990d6dc33d705b756e13dd135466c06b3b588ac845e0201000000001976a9145fb0e9755a3424efd2ba0587d20b1e98ee29814a88ac06241559", null);
|
||||||
addTransactionTab("p2sh", "0100000003a5ee1a0fd80dfbc3142df136ab56e082b799c13aa977c048bdf8f61bd158652c000000006b48304502203b0160de302cded63589a88214fe499a25aa1d86a2ea09129945cd632476a12c022100c77727daf0718307e184d55df620510cf96d4b5814ae3258519c0482c1ca82fa0121024f4102c1f1cf662bf99f2b034eb03edd4e6c96793cb9445ff519aab580649120ffffffff0fce901eb7b7551ba5f414735ff93b83a2a57403df11059ec88245fba2aaf1a0000000006a47304402204089adb8a1de1a9e22aa43b94d54f1e54dc9bea745d57df1a633e03dd9ede3c2022037d1e53e911ed7212186028f2e085f70524930e22eb6184af090ba4ab779a5b90121030644cb394bf381dbec91680bdf1be1986ad93cfb35603697353199fb285a119effffffff0fce901eb7b7551ba5f414735ff93b83a2a57403df11059ec88245fba2aaf1a0010000009300493046022100a07b2821f96658c938fa9c68950af0e69f3b2ce5f8258b3a6ad254d4bc73e11e022100e82fab8df3f7e7a28e91b3609f91e8ebf663af3a4dc2fd2abd954301a5da67e701475121022afc20bf379bc96a2f4e9e63ffceb8652b2b6a097f63fbee6ecec2a49a48010e2103a767c7221e9f15f870f1ad9311f5ab937d79fcaeee15bb2c722bca515581b4c052aeffffffff02a3b81b00000000001976a914ea00917f128f569cbdf79da5efcd9001671ab52c88ac80969800000000001976a9143dec0ead289be1afa8da127a7dbdd425a05e25f688ac00000000", null);
|
addTransactionTab("p2sh", "0100000003a5ee1a0fd80dfbc3142df136ab56e082b799c13aa977c048bdf8f61bd158652c000000006b48304502203b0160de302cded63589a88214fe499a25aa1d86a2ea09129945cd632476a12c022100c77727daf0718307e184d55df620510cf96d4b5814ae3258519c0482c1ca82fa0121024f4102c1f1cf662bf99f2b034eb03edd4e6c96793cb9445ff519aab580649120ffffffff0fce901eb7b7551ba5f414735ff93b83a2a57403df11059ec88245fba2aaf1a0000000006a47304402204089adb8a1de1a9e22aa43b94d54f1e54dc9bea745d57df1a633e03dd9ede3c2022037d1e53e911ed7212186028f2e085f70524930e22eb6184af090ba4ab779a5b90121030644cb394bf381dbec91680bdf1be1986ad93cfb35603697353199fb285a119effffffff0fce901eb7b7551ba5f414735ff93b83a2a57403df11059ec88245fba2aaf1a0010000009300493046022100a07b2821f96658c938fa9c68950af0e69f3b2ce5f8258b3a6ad254d4bc73e11e022100e82fab8df3f7e7a28e91b3609f91e8ebf663af3a4dc2fd2abd954301a5da67e701475121022afc20bf379bc96a2f4e9e63ffceb8652b2b6a097f63fbee6ecec2a49a48010e2103a767c7221e9f15f870f1ad9311f5ab937d79fcaeee15bb2c722bca515581b4c052aeffffffff02a3b81b00000000001976a914ea00917f128f569cbdf79da5efcd9001671ab52c88ac80969800000000001976a9143dec0ead289be1afa8da127a7dbdd425a05e25f688ac00000000", null);
|
||||||
addTransactionTab("p2sh-p2wpkh", "01000000000101db6b1b20aa0fd7b23880be2ecbd4a98130974cf4748fb66092ac4d3ceb1a5477010000001716001479091972186c449eb1ded22b78e40d009bdf0089feffffff02b8b4eb0b000000001976a914a457b684d7f0d539a46a45bbc043f35b59d0d96388ac0008af2f000000001976a914fd270b1ee6abcaea97fea7ad0402e8bd8ad6d77c88ac02473044022047ac8e878352d3ebbde1c94ce3a10d057c24175747116f8288e5d794d12d482f0220217f36a485cae903c713331d877c1f64677e3622ad4010726870540656fe9dcb012103ad1d8e89212f0b92c74d23bb710c00662ad1470198ac48c43f7d6f93a2a2687392040000", null);
|
addTransactionTab("p2sh-p2wpkh", "01000000000101db6b1b20aa0fd7b23880be2ecbd4a98130974cf4748fb66092ac4d3ceb1a5477010000001716001479091972186c449eb1ded22b78e40d009bdf0089feffffff02b8b4eb0b000000001976a914a457b684d7f0d539a46a45bbc043f35b59d0d96388ac0008af2f000000001976a914fd270b1ee6abcaea97fea7ad0402e8bd8ad6d77c88ac02473044022047ac8e878352d3ebbde1c94ce3a10d057c24175747116f8288e5d794d12d482f0220217f36a485cae903c713331d877c1f64677e3622ad4010726870540656fe9dcb012103ad1d8e89212f0b92c74d23bb710c00662ad1470198ac48c43f7d6f93a2a2687392040000", null);
|
||||||
addTransactionTab("p2wpkh", "01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000", null);
|
addTransactionTab("p2sh-p2wsh", "01000000000101708256c5896fb3f00ef37601f8e30c5b460dbcd1fca1cd7199f9b56fc4ecd5400000000023220020615ae01ed1bc1ffaad54da31d7805d0bb55b52dfd3941114330368c1bbf69b4cffffffff01603edb0300000000160014bbef244bcad13cffb68b5cef3017c7423675552204004730440220010d2854b86b90b7c33661ca25f9d9f15c24b88c5c4992630f77ff004b998fb802204106fc3ec8481fa98e07b7e78809ac91b6ccaf60bf4d3f729c5a75899bb664a501473044022046d66321c6766abcb1366a793f9bfd0e11e0b080354f18188588961ea76c5ad002207262381a0661d66f5c39825202524c45f29d500c6476176cd910b1691176858701695221026ccfb8061f235cc110697c0bfb3afb99d82c886672f6b9b5393b25a434c0cbf32103befa190c0c22e2f53720b1be9476dcf11917da4665c44c9c71c3a2d28a933c352102be46dc245f58085743b1cc37c82f0d63a960efa43b5336534275fc469b49f4ac53ae00000000", null);
|
||||||
addTransactionTab("p2wsh", "01000000000102fe3dc9208094f3ffd12645477b3dc56f60ec4fa8e6f5d67c565d1c6b9216b36e000000004847304402200af4e47c9b9629dbecc21f73af989bdaa911f7e6f6c2e9394588a3aa68f81e9902204f3fcf6ade7e5abb1295b6774c8e0abd94ae62217367096bc02ee5e435b67da201ffffffff0815cf020f013ed6cf91d29f4202e8a58726b1ac6c79da47c23d1bee0a6925f80000000000ffffffff0100f2052a010000001976a914a30741f8145e5acadf23f751864167f32e0963f788ac000347304402200de66acf4527789bfda55fc5459e214fa6083f936b430a762c629656216805ac0220396f550692cd347171cbc1ef1f51e15282e837bb2b30860dc77c8f78bc8501e503473044022027dc95ad6b740fe5129e7e62a75dd00f291a2aeb1200b84b09d9e3789406b6c002201a9ecd315dd6a0e632ab20bbb98948bc0c6fb204f2c286963bb48517a7058e27034721026dccc749adc2a9d0d89497ac511f760f45c47dc5ed9cf352a58ac706453880aeadab210255a9626aebf5e29c0e6538428ba0d1dcf6ca98ffdf086aa8ced5e0d0215ea465ac00000000", null);
|
addTransactionTab("p2wpkh", "01000000000101109d2e41430bfdec7e6dfb02bf78b5827eeb717ef25210ff3203b0db8c76c9260000000000ffffffff01a032eb0500000000160014bbef244bcad13cffb68b5cef3017c742367555220247304402202f7cac3494e521018ae0be4ca18517639ef7c00658d42a9f938b2b344c8454e2022039a54218832fad5d14b331329d9042c51ee6be287e95e49ee5b96fda1f5ce13f0121026ccfb8061f235cc110697c0bfb3afb99d82c886672f6b9b5393b25a434c0cbf300000000", null);
|
||||||
|
addTransactionTab("p2wsh", "0100000000010193a2db37b841b2a46f4e9bb63fe9c1012da3ab7fe30b9f9c974242778b5af8980000000000ffffffff01806fb307000000001976a914bbef244bcad13cffb68b5cef3017c7423675552288ac040047304402203cdcaf02a44e37e409646e8a506724e9e1394b890cb52429ea65bac4cc2403f1022024b934297bcd0c21f22cee0e48751c8b184cc3a0d704cae2684e14858550af7d01483045022100feb4e1530c13e72226dc912dcd257df90d81ae22dbddb5a3c2f6d86f81d47c8e022069889ddb76388fa7948aaa018b2480ac36132009bb9cfade82b651e88b4b137a01695221026ccfb8061f235cc110697c0bfb3afb99d82c886672f6b9b5393b25a434c0cbf32103befa190c0c22e2f53720b1be9476dcf11917da4665c44c9c71c3a2d28a933c352102be46dc245f58085743b1cc37c82f0d63a960efa43b5336534275fc469b49f4ac53ae00000000", null);
|
||||||
addTransactionTab("test1", "02000000000102ba4dc5a4a14bfaa941b7d115b379b5e15f960635cf694c178b9116763cbd63b11600000017160014fc164cbcac023f5eacfcead2d17d8768c41949affeffffff074d44d2856beb68ba52e8832da60a1682768c2421c2d9a8109ef4e66babd1fd1e000000171600148c3098be6b430859115f5ee99c84c368afecd048feffffff02305310000000000017a914ffaf369c2212b178c7a2c21c9ccdd5d126e74c4187327f0300000000001976a914a7cda2e06b102a143ab606937a01d152e300cd3e88ac02473044022006da0ca227f765179219e08a33026b94e7cacff77f87b8cd8eb1b46d6dda11d6022064faa7912924fd23406b6ed3328f1bbbc3760dc51109a49c1b38bf57029d304f012103c6a2fcd030270427d4abe1041c8af929a9e2dbab07b243673453847ab842ee1f024730440220786316a16095105a0af28dccac5cf80f449dea2ea810a9559a89ecb989c2cb3d02205cbd9913d1217ffec144ae4f2bd895f16d778c2ec49ae9c929fdc8bcc2a2b1db0121024d4985241609d072a59be6418d700e87688f6c4d99a51ad68e66078211f076ee38820900", null);
|
addTransactionTab("test1", "02000000000102ba4dc5a4a14bfaa941b7d115b379b5e15f960635cf694c178b9116763cbd63b11600000017160014fc164cbcac023f5eacfcead2d17d8768c41949affeffffff074d44d2856beb68ba52e8832da60a1682768c2421c2d9a8109ef4e66babd1fd1e000000171600148c3098be6b430859115f5ee99c84c368afecd048feffffff02305310000000000017a914ffaf369c2212b178c7a2c21c9ccdd5d126e74c4187327f0300000000001976a914a7cda2e06b102a143ab606937a01d152e300cd3e88ac02473044022006da0ca227f765179219e08a33026b94e7cacff77f87b8cd8eb1b46d6dda11d6022064faa7912924fd23406b6ed3328f1bbbc3760dc51109a49c1b38bf57029d304f012103c6a2fcd030270427d4abe1041c8af929a9e2dbab07b243673453847ab842ee1f024730440220786316a16095105a0af28dccac5cf80f449dea2ea810a9559a89ecb989c2cb3d02205cbd9913d1217ffec144ae4f2bd895f16d778c2ec49ae9c929fdc8bcc2a2b1db0121024d4985241609d072a59be6418d700e87688f6c4d99a51ad68e66078211f076ee38820900", null);
|
||||||
addTransactionTab("3of3-1signed.psbt", null, "70736274ff0100550200000001294c4871c059bb76be81e94b78059ee2e0c9b1b47f38edb6b4e75916062394930000000000feffffff01f82a0000000000001976a914e65b294f890792f2c2725d488567018d660f0cf488ac701c09004f0102aa7ed3044b1635bb800000021bf4bfc48934b7966b39bdebb689525d9b8bfed5c8b16e8c58f9afe4641d6d5f03800b5dbec0355c9f0b5e8227bc903e9d0ff1fe6ced0dcfb6d416541c7412c4331406b57041300000800000008000000080020000804f0102aa7ed3042cd31dee80000002d544b2364010378f8c6cec85f6b7ed83a8203dcdbedb97e2625f431f897b837e0363428de8fcfbfe373c0d9e1e0cc8163d886764bafe71c5822eaa232981356589145f63394f300000800000008000000080020000804f0102aa7ed3049ec7d9f580000002793e04aff18b4e40ebc48bcdc6232c54c69cf7265a38fbd85b35705e34d2d42f03368e79aa2b2b7f736d156905a7a45891df07baa2d0b7f127a537908cb82deed514130a48af300000800000008000000080020000800001012b983a000000000000220020f64748dad1cbad107761aaed5c59f25aba006498d260b440e0a091691350c9aa010569532102f26969eb8d1da34d17d33ff99e2f020cc33b3d11d9798ec14f46b82bc455d3262103171d9b824205cd5db6e9353676a292ca954b24d8310a36fc983469ba3fb507a221037f3794f3be4c4acc086ac84d6902c025713eabf8890f20f44acf0b34e3c0f0f753ae220602f26969eb8d1da34d17d33ff99e2f020cc33b3d11d9798ec14f46b82bc455d3261c130a48af300000800000008000000080020000800000000000000000220603171d9b824205cd5db6e9353676a292ca954b24d8310a36fc983469ba3fb507a21c5f63394f300000800000008000000080020000800000000000000000220203171d9b824205cd5db6e9353676a292ca954b24d8310a36fc983469ba3fb507a24830450221008d27cc4b03bc543726e73b69e7980e7364d6f33f979a5cd9b92fb3d050666bd002204fc81fc9c67baf7c3b77041ed316714a9c117a5bdbb020e8c771ea3bdc342434012206037f3794f3be4c4acc086ac84d6902c025713eabf8890f20f44acf0b34e3c0f0f71c06b570413000008000000080000000800200008000000000000000000000");
|
addTransactionTab("3of3-1signed.psbt", null, "70736274ff0100550200000001294c4871c059bb76be81e94b78059ee2e0c9b1b47f38edb6b4e75916062394930000000000feffffff01f82a0000000000001976a914e65b294f890792f2c2725d488567018d660f0cf488ac701c09004f0102aa7ed3044b1635bb800000021bf4bfc48934b7966b39bdebb689525d9b8bfed5c8b16e8c58f9afe4641d6d5f03800b5dbec0355c9f0b5e8227bc903e9d0ff1fe6ced0dcfb6d416541c7412c4331406b57041300000800000008000000080020000804f0102aa7ed3042cd31dee80000002d544b2364010378f8c6cec85f6b7ed83a8203dcdbedb97e2625f431f897b837e0363428de8fcfbfe373c0d9e1e0cc8163d886764bafe71c5822eaa232981356589145f63394f300000800000008000000080020000804f0102aa7ed3049ec7d9f580000002793e04aff18b4e40ebc48bcdc6232c54c69cf7265a38fbd85b35705e34d2d42f03368e79aa2b2b7f736d156905a7a45891df07baa2d0b7f127a537908cb82deed514130a48af300000800000008000000080020000800001012b983a000000000000220020f64748dad1cbad107761aaed5c59f25aba006498d260b440e0a091691350c9aa010569532102f26969eb8d1da34d17d33ff99e2f020cc33b3d11d9798ec14f46b82bc455d3262103171d9b824205cd5db6e9353676a292ca954b24d8310a36fc983469ba3fb507a221037f3794f3be4c4acc086ac84d6902c025713eabf8890f20f44acf0b34e3c0f0f753ae220602f26969eb8d1da34d17d33ff99e2f020cc33b3d11d9798ec14f46b82bc455d3261c130a48af300000800000008000000080020000800000000000000000220603171d9b824205cd5db6e9353676a292ca954b24d8310a36fc983469ba3fb507a21c5f63394f300000800000008000000080020000800000000000000000220203171d9b824205cd5db6e9353676a292ca954b24d8310a36fc983469ba3fb507a24830450221008d27cc4b03bc543726e73b69e7980e7364d6f33f979a5cd9b92fb3d050666bd002204fc81fc9c67baf7c3b77041ed316714a9c117a5bdbb020e8c771ea3bdc342434012206037f3794f3be4c4acc086ac84d6902c025713eabf8890f20f44acf0b34e3c0f0f71c06b570413000008000000080000000800200008000000000000000000000");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.sparrowwallet.sparrow.transaction;
|
package com.sparrowwallet.sparrow.transaction;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.protocol.Script;
|
||||||
|
import com.sparrowwallet.drongo.protocol.ScriptChunk;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionInput;
|
import com.sparrowwallet.drongo.protocol.TransactionInput;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -11,6 +13,7 @@ import tornadofx.control.Fieldset;
|
||||||
import org.fxmisc.flowless.VirtualizedScrollPane;
|
import org.fxmisc.flowless.VirtualizedScrollPane;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class InputController extends TransactionFormController implements Initializable {
|
public class InputController extends TransactionFormController implements Initializable {
|
||||||
|
@ -26,13 +29,25 @@ public class InputController extends TransactionFormController implements Initia
|
||||||
private Button outpointSelect;
|
private Button outpointSelect;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private CodeArea scriptSig;
|
private CodeArea scriptSigArea;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private VirtualizedScrollPane<CodeArea> witnessScrollPane;
|
private VirtualizedScrollPane<CodeArea> redeemScriptScroll;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private CodeArea witness;
|
private CodeArea redeemScriptArea;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private VirtualizedScrollPane<CodeArea> witnessScriptScroll;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CodeArea witnessScriptArea;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private VirtualizedScrollPane<CodeArea> witnessesScroll;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CodeArea witnessesArea;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
@ -49,17 +64,35 @@ public class InputController extends TransactionFormController implements Initia
|
||||||
//TODO: Enable select outpoint when wallet present
|
//TODO: Enable select outpoint when wallet present
|
||||||
outpointSelect.setDisable(true);
|
outpointSelect.setDisable(true);
|
||||||
|
|
||||||
scriptSig.clear();
|
//TODO: Is this safe?
|
||||||
appendScript(scriptSig, txInput.getScriptSig().toDisplayString());
|
Script redeemScript = txInput.getScriptSig().getFirstNestedScript();
|
||||||
|
|
||||||
witness.clear();
|
scriptSigArea.clear();
|
||||||
if(txInput.hasWitness()) {
|
appendScript(scriptSigArea, txInput.getScriptSig(), redeemScript, null);
|
||||||
appendScript(witness, txInput.getWitness().toDisplayString());
|
|
||||||
|
redeemScriptArea.clear();
|
||||||
|
if(redeemScript != null) {
|
||||||
|
appendScript(redeemScriptArea, redeemScript);
|
||||||
} else {
|
} else {
|
||||||
witnessScrollPane.setDisable(true);
|
redeemScriptScroll.setDisable(true);
|
||||||
witness.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
witnessesArea.clear();
|
||||||
|
witnessScriptArea.clear();
|
||||||
|
if(txInput.hasWitness()) {
|
||||||
|
List<ScriptChunk> witnessChunks = txInput.getWitness().asScriptChunks();
|
||||||
|
if(witnessChunks.get(witnessChunks.size() - 1).isScript()) {
|
||||||
|
Script witnessScript = new Script(witnessChunks.get(witnessChunks.size() - 1).getData());
|
||||||
|
appendScript(witnessesArea, new Script(witnessChunks.subList(0, witnessChunks.size() - 1)), null, witnessScript);
|
||||||
|
appendScript(witnessScriptArea, witnessScript);
|
||||||
|
} else {
|
||||||
|
appendScript(witnessesArea, new Script(witnessChunks));
|
||||||
|
witnessScriptScroll.setDisable(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
witnessesScroll.setDisable(true);
|
||||||
|
witnessScriptScroll.setDisable(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(InputForm form) {
|
public void setModel(InputForm form) {
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.sparrowwallet.sparrow.transaction;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.protocol.ScriptChunk;
|
||||||
|
import javafx.scene.control.ContextMenu;
|
||||||
|
import javafx.scene.control.IndexRange;
|
||||||
|
import javafx.scene.control.MenuItem;
|
||||||
|
import javafx.scene.input.Clipboard;
|
||||||
|
import javafx.scene.input.ClipboardContent;
|
||||||
|
import org.fxmisc.richtext.CodeArea;
|
||||||
|
|
||||||
|
public class ScriptContextMenu extends ContextMenu {
|
||||||
|
private MenuItem copyvalue;
|
||||||
|
private CodeArea area;
|
||||||
|
private IndexRange range;
|
||||||
|
private ScriptChunk hoverChunk;
|
||||||
|
|
||||||
|
public ScriptContextMenu()
|
||||||
|
{
|
||||||
|
showingProperty().addListener((ob,ov,showing) -> checkMenuItems(showing));
|
||||||
|
this.
|
||||||
|
|
||||||
|
copyvalue = new MenuItem("Copy Value");
|
||||||
|
copyvalue.setOnAction(AE -> {
|
||||||
|
hide();
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(hoverChunk.toString());
|
||||||
|
Clipboard.getSystemClipboard().setContent(content);
|
||||||
|
});
|
||||||
|
|
||||||
|
getItems().add(copyvalue);
|
||||||
|
|
||||||
|
this.setStyle("-fx-background-color: -fx-color; -fx-font-family: sans-serif; -fx-font-size: 1em;");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkMenuItems(boolean showing)
|
||||||
|
{
|
||||||
|
if(!showing) return;
|
||||||
|
area = (CodeArea)getOwnerNode();
|
||||||
|
|
||||||
|
range = area.getSelection();
|
||||||
|
copyvalue.setDisable(hoverChunk == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHoverChunk(ScriptChunk hoverChunk) {
|
||||||
|
this.hoverChunk = hoverChunk;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,23 @@
|
||||||
package com.sparrowwallet.sparrow.transaction;
|
package com.sparrowwallet.sparrow.transaction;
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.address.Address;
|
import com.sparrowwallet.drongo.address.Address;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
import com.sparrowwallet.drongo.protocol.*;
|
||||||
import com.sparrowwallet.drongo.protocol.NonStandardScriptException;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.chart.PieChart;
|
import javafx.scene.chart.PieChart;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.stage.Popup;
|
||||||
import org.fxmisc.richtext.CodeArea;
|
import org.fxmisc.richtext.CodeArea;
|
||||||
|
import org.fxmisc.richtext.event.MouseOverTextEvent;
|
||||||
|
import org.fxmisc.richtext.model.TwoDimensional;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.fxmisc.richtext.model.TwoDimensional.Bias.Backward;
|
||||||
|
|
||||||
public abstract class TransactionFormController {
|
public abstract class TransactionFormController {
|
||||||
protected void addPieData(PieChart pie, List<TransactionOutput> outputs) {
|
protected void addPieData(PieChart pie, List<TransactionOutput> outputs) {
|
||||||
ObservableList<PieChart.Data> outputsPieData = FXCollections.observableArrayList();
|
ObservableList<PieChart.Data> outputsPieData = FXCollections.observableArrayList();
|
||||||
|
@ -45,41 +52,83 @@ public abstract class TransactionFormController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void appendScript(CodeArea codeArea, String script) {
|
protected void appendScript(CodeArea codeArea, Script script) {
|
||||||
String[] parts = script.split(" ");
|
appendScript(codeArea, script, null, null);
|
||||||
for (int i = 0; i < parts.length; i++) {
|
|
||||||
String part = parts[i];
|
|
||||||
|
|
||||||
if(part.startsWith("(")) {
|
|
||||||
codeArea.append("(", "script-nest");
|
|
||||||
part = part.substring(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean appendCloseBracket = false;
|
protected void appendScript(CodeArea codeArea, Script script, Script redeemScript, Script witnessScript) {
|
||||||
if(part.endsWith(")")) {
|
if(ScriptPattern.isP2WPKH(script)) {
|
||||||
appendCloseBracket = true;
|
codeArea.append(script.getChunks().get(0).toString(), "script-opcode");
|
||||||
part = part.substring(0, part.length() - 1);
|
codeArea.append(" ", "");
|
||||||
}
|
codeArea.append("<wpkh>", "script-hash");
|
||||||
|
} else if(ScriptPattern.isP2WSH(script)) {
|
||||||
if(part.startsWith("OP")) {
|
codeArea.append(script.getChunks().get(0).toString(), "script-opcode");
|
||||||
codeArea.append(part, "script-opcode");
|
codeArea.append(" ", "");
|
||||||
} else if(part.startsWith("<signature")) {
|
codeArea.append("<wsh>", "script-hash");
|
||||||
codeArea.append(part, "script-signature");
|
|
||||||
} else if(part.startsWith("<pubkey")) {
|
|
||||||
codeArea.append(part, "script-pubkey");
|
|
||||||
} else if(part.startsWith("<wpkh") || part.startsWith("<wsh")) {
|
|
||||||
codeArea.append(part, "script-type");
|
|
||||||
} else {
|
} else {
|
||||||
codeArea.append(part, "script-other");
|
int signatureCount = 1;
|
||||||
}
|
int pubKeyCount = 1;
|
||||||
|
for (int i = 0; i < script.getChunks().size(); i++) {
|
||||||
if(appendCloseBracket) {
|
ScriptChunk chunk = script.getChunks().get(i);
|
||||||
|
if(chunk.isOpCode()) {
|
||||||
|
codeArea.append(chunk.toString(), "script-opcode");
|
||||||
|
} else if(chunk.isSignature()) {
|
||||||
|
codeArea.append("<signature" + signatureCount++ + ">", "script-signature");
|
||||||
|
} else if(chunk.isScript()) {
|
||||||
|
Script nestedScript = new Script(chunk.getData());
|
||||||
|
if (nestedScript.equals(redeemScript)) {
|
||||||
|
codeArea.append("<RedeemScript>", "script-redeem");
|
||||||
|
} else if (nestedScript.equals(witnessScript)) {
|
||||||
|
codeArea.append("<WitnessScript>", "script-redeem");
|
||||||
|
} else {
|
||||||
|
codeArea.append("(", "script-nest");
|
||||||
|
appendScript(codeArea, nestedScript);
|
||||||
codeArea.append(")", "script-nest");
|
codeArea.append(")", "script-nest");
|
||||||
}
|
}
|
||||||
|
} else if(chunk.isPubKey()) {
|
||||||
|
codeArea.append("<pubkey" + pubKeyCount++ + ">", "script-pubkey");
|
||||||
|
} else {
|
||||||
|
System.out.println(chunk.isOpCode() + " " + chunk.opcode);
|
||||||
|
codeArea.append(chunk.toString(), "script-other");
|
||||||
|
}
|
||||||
|
|
||||||
if(i < parts.length - 1) {
|
if(i < script.getChunks().size() - 1) {
|
||||||
codeArea.append(" ", "");
|
codeArea.append(" ", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addScriptPopup(codeArea, script);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addScriptPopup(CodeArea area, Script script) {
|
||||||
|
ScriptContextMenu contextMenu = new ScriptContextMenu();
|
||||||
|
area.setContextMenu(contextMenu);
|
||||||
|
|
||||||
|
Popup popup = new Popup();
|
||||||
|
Label popupMsg = new Label();
|
||||||
|
popupMsg.setStyle("-fx-background-color: #696c77; -fx-text-fill: white; -fx-padding: 5;");
|
||||||
|
popup.getContent().add(popupMsg);
|
||||||
|
|
||||||
|
area.setMouseOverTextDelay(Duration.ofMillis(150));
|
||||||
|
area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_BEGIN, e -> {
|
||||||
|
TwoDimensional.Position position = area.getParagraph(0).getStyleSpans().offsetToPosition(e.getCharacterIndex(), Backward);
|
||||||
|
if(position.getMajor() % 2 == 0) {
|
||||||
|
ScriptChunk hoverChunk = script.getChunks().get(position.getMajor()/2);
|
||||||
|
if(!hoverChunk.isOpCode()) {
|
||||||
|
contextMenu.setHoverChunk(hoverChunk);
|
||||||
|
Point2D pos = e.getScreenPosition();
|
||||||
|
popupMsg.setText(hoverChunk.toString());
|
||||||
|
popup.show(area, pos.getX(), pos.getY() + 10);
|
||||||
|
} else {
|
||||||
|
contextMenu.setHoverChunk(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
contextMenu.setHoverChunk(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_END, e -> {
|
||||||
|
popup.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.form .fieldset:horizontal .label-container {
|
.form .fieldset:horizontal .label-container {
|
||||||
-fx-pref-width: 90px;
|
-fx-pref-width: 110px;
|
||||||
-fx-pref-height: 25px;
|
-fx-pref-height: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
||||||
</padding>
|
</padding>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints minWidth="330" prefWidth="330"
|
<ColumnConstraints minWidth="340" prefWidth="340"
|
||||||
maxWidth="Infinity">
|
maxWidth="Infinity">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
<ColumnConstraints minWidth="330" prefWidth="330"
|
<ColumnConstraints minWidth="340" prefWidth="340"
|
||||||
maxWidth="Infinity">
|
maxWidth="Infinity">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
|
|
||||||
.script-nest { -fx-fill: #000000 }
|
.script-nest { -fx-fill: #000000 }
|
||||||
.script-opcode { -fx-fill: #0184bc; }
|
.script-opcode { -fx-fill: #0184bc; }
|
||||||
|
.script-hash { -fx-fill: #986801; }
|
||||||
.script-signature { -fx-fill: #50a14f }
|
.script-signature { -fx-fill: #50a14f }
|
||||||
.script-pubkey { -fx-fill: #a626a4 }
|
.script-pubkey { -fx-fill: #a626a4 }
|
||||||
|
.script-redeem { -fx-fill: #ca1243 }
|
||||||
.script-other { -fx-fill: #a0a1a7 }
|
.script-other { -fx-fill: #a0a1a7 }
|
||||||
.script-type { -fx-fill: #986801 }
|
|
||||||
|
|
||||||
.uneditable-codearea {
|
.uneditable-codearea {
|
||||||
-fx-font: 14px Courier;
|
-fx-font: 14px Courier;
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
||||||
</padding>
|
</padding>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints maxWidth="Infinity" minWidth="330" prefWidth="330">
|
<ColumnConstraints maxWidth="Infinity" minWidth="340" prefWidth="340">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
<ColumnConstraints maxWidth="Infinity" minWidth="330" prefWidth="330">
|
<ColumnConstraints maxWidth="Infinity" minWidth="340" prefWidth="340">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
|
@ -43,16 +43,34 @@
|
||||||
<HBox>
|
<HBox>
|
||||||
<VirtualizedScrollPane prefHeight="42">
|
<VirtualizedScrollPane prefHeight="42">
|
||||||
<content>
|
<content>
|
||||||
<CodeArea fx:id="scriptSig" editable="false" minWidth="570" prefWidth="570" wrapText="true" styleClass="uneditable-codearea" />
|
<CodeArea fx:id="scriptSigArea" editable="false" minWidth="570" prefWidth="570" wrapText="true" styleClass="uneditable-codearea" />
|
||||||
</content>
|
</content>
|
||||||
</VirtualizedScrollPane>
|
</VirtualizedScrollPane>
|
||||||
</HBox>
|
</HBox>
|
||||||
</Field>
|
</Field>
|
||||||
<Field text="Witness:">
|
<Field text="RedeemScript:">
|
||||||
<HBox>
|
<HBox>
|
||||||
<VirtualizedScrollPane fx:id="witnessScrollPane" prefHeight="42">
|
<VirtualizedScrollPane fx:id="redeemScriptScroll" prefHeight="42">
|
||||||
<content>
|
<content>
|
||||||
<CodeArea fx:id="witness" editable="false" minWidth="570" prefWidth="570" wrapText="true" styleClass="uneditable-codearea" />
|
<CodeArea fx:id="redeemScriptArea" editable="false" minWidth="570" prefWidth="570" wrapText="true" styleClass="uneditable-codearea" />
|
||||||
|
</content>
|
||||||
|
</VirtualizedScrollPane>
|
||||||
|
</HBox>
|
||||||
|
</Field>
|
||||||
|
<Field text="Witnesses:">
|
||||||
|
<HBox>
|
||||||
|
<VirtualizedScrollPane fx:id="witnessesScroll" prefHeight="42">
|
||||||
|
<content>
|
||||||
|
<CodeArea fx:id="witnessesArea" editable="false" minWidth="570" prefWidth="570" wrapText="true" styleClass="uneditable-codearea" />
|
||||||
|
</content>
|
||||||
|
</VirtualizedScrollPane>
|
||||||
|
</HBox>
|
||||||
|
</Field>
|
||||||
|
<Field text="WitnessScript:">
|
||||||
|
<HBox>
|
||||||
|
<VirtualizedScrollPane fx:id="witnessScriptScroll" prefHeight="42">
|
||||||
|
<content>
|
||||||
|
<CodeArea fx:id="witnessScriptArea" editable="false" minWidth="570" prefWidth="570" wrapText="true" styleClass="uneditable-codearea" />
|
||||||
</content>
|
</content>
|
||||||
</VirtualizedScrollPane>
|
</VirtualizedScrollPane>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
||||||
</padding>
|
</padding>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints maxWidth="Infinity" minWidth="330" prefWidth="330">
|
<ColumnConstraints maxWidth="Infinity" minWidth="340" prefWidth="340">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
<ColumnConstraints maxWidth="Infinity" minWidth="330" prefWidth="330">
|
<ColumnConstraints maxWidth="Infinity" minWidth="340" prefWidth="340">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
|
||||||
</padding>
|
</padding>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints maxWidth="Infinity" minWidth="330" prefWidth="330">
|
<ColumnConstraints maxWidth="Infinity" minWidth="340" prefWidth="340">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
<ColumnConstraints maxWidth="Infinity" minWidth="330" prefWidth="330">
|
<ColumnConstraints maxWidth="Infinity" minWidth="340" prefWidth="340">
|
||||||
</ColumnConstraints>
|
</ColumnConstraints>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
|
|
Loading…
Reference in a new issue