File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
chainsql/src/main/java/com/peersafe/chainsql Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 15
15
import com .peersafe .base .core .types .known .tx .Transaction ;
16
16
import com .peersafe .chainsql .util .Util ;
17
17
18
+ import static com .peersafe .base .config .Config .getB58IdentiferCodecs ;
19
+
18
20
/**
19
21
* @author mail_
20
22
*
@@ -81,6 +83,13 @@ protected JSONObject prepareSigned() {
81
83
private Ripple pay (String accountId ,Amount amount ){
82
84
mTxJson = new JSONObject ();
83
85
mTxJson .put ("Account" , this .connection .address );
86
+
87
+ String addrPrefix = accountId .substring (0 ,2 );
88
+ if (addrPrefix .equals ("0x" ))
89
+ {
90
+ byte [] addrByte = Util .hexToBytes (accountId .substring (2 ));
91
+ accountId = getB58IdentiferCodecs ().encodeAddress (addrByte );
92
+ }
84
93
if (amount .currency () != Currency .ZXC )
85
94
{
86
95
JSONObject result = this .connection .client .accountInfo (amount .issuer ());
Original file line number Diff line number Diff line change 26
26
import com .peersafe .base .utils .Utils ;
27
27
import com .peersafe .chainsql .crypto .EncryptCommon ;
28
28
import com .peersafe .chainsql .net .Connection ;
29
+ import com .peersafe .base .encodings .common .B16 ;
29
30
30
31
31
32
public class Util {
@@ -115,11 +116,12 @@ public static String bytesToHex(byte[] bytes) {
115
116
* @return Hexed byte array.
116
117
*/
117
118
public static byte [] hexToBytes (String bytes ){
118
- ByteArrayOutputStream baos =new ByteArrayOutputStream (bytes .length ()/2 );
119
- //将每2位16进制整数组装成一个字节
120
- for (int i =0 ;i <bytes .length ();i +=2 )
121
- baos .write ((hexString .indexOf (bytes .charAt (i ))<<4 |hexString .indexOf (bytes .charAt (i +1 ))));
122
- return baos .toByteArray ();
119
+ return B16 .decode (bytes );
120
+ // ByteArrayOutputStream baos=new ByteArrayOutputStream(bytes.length()/2);
121
+ // //将每2位16进制整数组装成一个字节
122
+ // for(int i=0;i<bytes.length();i+=2)
123
+ // baos.write((hexString.indexOf(bytes.charAt(i))<<4 |hexString.indexOf(bytes.charAt(i+1))));
124
+ // return baos.toByteArray();
123
125
}
124
126
125
127
/**
You can’t perform that action at this time.
0 commit comments