| 643 | (buff)[15] = 0xA8; |
| 644 | |
| 645 | std::vector<std::string> Secp256K1::GetAddress(int type, bool compressed, unsigned char *h1, unsigned char *h2, unsigned char *h3, unsigned char *h4) { |
| 646 | |
| 647 | std::vector<std::string> ret; |
| 648 | |
| 649 | unsigned char add1[25]; |
| 650 | unsigned char add2[25]; |
| 651 | unsigned char add3[25]; |
| 652 | unsigned char add4[25]; |
| 653 | uint32_t b1[16]; |
| 654 | uint32_t b2[16]; |
| 655 | uint32_t b3[16]; |
| 656 | uint32_t b4[16]; |
| 657 | |
| 658 | switch (type) { |
| 659 | |
| 660 | case P2PKH: |
| 661 | add1[0] = 0x00; |
| 662 | add2[0] = 0x00; |
| 663 | add3[0] = 0x00; |
| 664 | add4[0] = 0x00; |
| 665 | break; |
| 666 | |
| 667 | case P2SH: |
| 668 | add1[0] = 0x05; |
| 669 | add2[0] = 0x05; |
| 670 | add3[0] = 0x05; |
| 671 | add4[0] = 0x05; |
| 672 | break; |
| 673 | |
| 674 | case BECH32: |
| 675 | { |
| 676 | char output[128]; |
| 677 | segwit_addr_encode(output, "bc", 0, h1, 20); |
| 678 | ret.push_back(std::string(output)); |
| 679 | segwit_addr_encode(output, "bc", 0, h2, 20); |
| 680 | ret.push_back(std::string(output)); |
| 681 | segwit_addr_encode(output, "bc", 0, h3, 20); |
| 682 | ret.push_back(std::string(output)); |
| 683 | segwit_addr_encode(output, "bc", 0, h4, 20); |
| 684 | ret.push_back(std::string(output)); |
| 685 | return ret; |
| 686 | } |
| 687 | break; |
| 688 | } |
| 689 | |
| 690 | memcpy(add1 + 1, h1, 20); |
| 691 | memcpy(add2 + 1, h2, 20); |
| 692 | memcpy(add3 + 1, h3, 20); |
| 693 | memcpy(add4 + 1, h4, 20); |
| 694 | CHECKSUM(b1, add1); |
| 695 | CHECKSUM(b2, add2); |
| 696 | CHECKSUM(b3, add3); |
| 697 | CHECKSUM(b4, add4); |
| 698 | sha256sse_checksum(b1,b2,b3,b4,add1 + 21, add2 + 21, add3 + 21, add4 + 21); |
| 699 | |
| 700 | // Base58 |
| 701 | ret.push_back(EncodeBase58(add1, add1 + 25)); |
| 702 | ret.push_back(EncodeBase58(add2, add2 + 25)); |
no test coverage detected